-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconnect-polylang-elementor.php
153 lines (123 loc) · 4.64 KB
/
connect-polylang-elementor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php # -*- coding: utf-8 -*-
/**
* Main plugin file.
* @package Polylang Connect for Elementor
* @author David Decker
* @copyright Copyright (c) 2018, David Decker - DECKERWEB
* @license GPL-2.0-or-later
* @link https://deckerweb.de/twitter
*
* @wordpress-plugin
* Plugin Name: Polylang Connect for Elementor
* Plugin URI: https://github.com/deckerweb/connect-polylang-elementor
* Description: Connect the Polylang multilingual plugin with Elementor Page Builder: This plugin will make Elementor and Polylang show the correct language templates, especially with Elementor Pro Theme Builder. Plus: native Polylang Language Switcher Elementor widget, new Dynamic Tags, and Polylang links added to the Elementor Finder feature.
* Version: 1.0.0
* Author: David Decker - DECKERWEB
* Author URI: https://deckerweb.de/
* License: GPL-2.0-or-later
* License URI: https://opensource.org/licenses/GPL-2.0
* Text Domain: connect-polylang-elementor
* Domain Path: /languages/
* Requires WP: 4.7
* Requires PHP: 5.6
* GitHub Plugin URI: https://github.com/deckerweb/connect-polylang-elementor
* GitHub Branch: master
*
* Copyright (c) 2018 David Decker - DECKERWEB
*/
/**
* Exit if called directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit( 'Sorry, you are not allowed to access this file directly.' );
}
/**
* Setting constants.
*
* @since 1.0.0
*/
/** Plugin version */
define( 'CPEL_PLUGIN_VERSION', '1.0.0' );
/** File */
define( 'CPEL__FILE__', __FILE__ );
/** Plugin directory */
define( 'CPEL_PLUGIN_DIR', trailingslashit( dirname( __FILE__ ) ) );
/** Plugin base directory */
define( 'CPEL_PLUGIN_BASEDIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
add_action( 'plugins_loaded', 'ddw_cpel_load_translations', 10 );
/**
* Load the text domain for translation of the plugin.
*
* @since 1.0.0
*
* @uses get_user_locale()
* @uses load_textdomain() Load translations first from WP_LANG_DIR sub folder.
* @uses load_plugin_textdomain() Additionally load default translations from
* plugin folder (default).
*/
function ddw_cpel_load_translations() {
/** Set unique textdomain string */
$cpel_textdomain = 'connect-polylang-elementor';
/** The 'plugin_locale' filter is also used by default in load_plugin_textdomain() */
$locale = esc_attr(
apply_filters(
'plugin_locale',
get_user_locale(),
$cpel_textdomain
)
);
/**
* WordPress languages directory
* Will default to: wp-content/languages/connect-polylang-elementor/connect-polylang-elementor-{locale}.mo
*/
$cpel_wp_lang_dir = trailingslashit( WP_LANG_DIR ) . trailingslashit( $cpel_textdomain ) . $cpel_textdomain . '-' . $locale . '.mo';
/** Translations: First, look in WordPress' "languages" folder = custom & update-safe! */
load_textdomain(
$cpel_textdomain,
$cpel_wp_lang_dir
);
/** Translations: Secondly, look in 'wp-content/languages/plugins/' for the proper .mo file (= default) */
load_plugin_textdomain(
$cpel_textdomain,
FALSE,
CPEL_PLUGIN_BASEDIR . 'languages'
);
} // end function
/** Include global functions */
require_once( CPEL_PLUGIN_DIR . 'includes/functions-global.php' );
/** Include (global) conditionals functions */
require_once( CPEL_PLUGIN_DIR . 'includes/functions-conditionals.php' );
add_action( 'plugins_loaded', 'ddw_cpel_setup_plugin', 20 );
/**
* Finally setup the plugin for the main tasks.
*
* @since 1.0.0
*/
function ddw_cpel_setup_plugin() {
/** Load features that require Polylang & Elementor active */
if ( ddw_cpel_is_polylang_active() && ddw_cpel_is_elementor_active() ) {
require_once( CPEL_PLUGIN_DIR . 'modules/finder/manager.php' );
require_once( CPEL_PLUGIN_DIR . 'modules/widgets/register-widget.php' );
new \DDW_Connect_Polylang_Elementor\Register_Widget();
/** Load features that require Elementor Pro */
if ( ddw_cpel_is_elementor_pro_active() ) {
require_once( CPEL_PLUGIN_DIR . 'modules/connect/tweaks-polylang-elementor.php' );
require_once( CPEL_PLUGIN_DIR . 'modules/dynamic-tags/manager.php' );
}
} // end if
/** Include admin helper functions */
if ( is_admin() ) {
require_once( CPEL_PLUGIN_DIR . 'includes/admin-extras.php' );
}
/** Add links to Settings and Menu pages to Plugins page */
if ( ( is_admin() || is_network_admin() ) ) {
add_filter(
'plugin_action_links_' . plugin_basename( __FILE__ ),
'ddw_cpel_custom_settings_links'
);
add_filter(
'network_admin_plugin_action_links_' . plugin_basename( __FILE__ ),
'ddw_cpel_custom_settings_links'
);
} // end if
} // end function