PluginProbe
Themify Builder / 7.7.1
Themify Builder v7.7.1
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / themify-builder.php

themify-builder.php in Themify Builder 7.7.1, at themify-builder.php

256 lines 9.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Themify Builder
4 Plugin URI: https://themify.me/builder
5 Description: Build responsive layouts that work for any device using intuitive "what you see is what you get" drag & drop framework, with live edits and previews.
6 Version: 7.7.1
7 Author: Themify
8 Author URI: https://themify.me
9 Text Domain: themify
10 Requires PHP: 7.4
11 Domain Path: /languages
12 */
13
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17
18 /**
19 * Disable the plugin if using a Themify theme: Builder is included in the theme.
20 *
21 * @return void
22 */
23 function themify_builder_theme_check() {
24 if ( is_file( trailingslashit( get_template_directory() ) . 'themify/themify-utils.php' ) ) {
25 ?>
26 <div class="error">
27 <p><?php _e( 'You are using a Themify theme. The Builder is included in the theme framework. No need to install Builder plugin.', 'themify' ); ?></p>
28 </div>
29 <?php
30 deactivate_plugins( plugin_basename( __FILE__ ), true );
31 }
32 }
33 if(is_admin()){
34 add_action( 'admin_notices', 'themify_builder_theme_check' );
35 }
36
37 // Hook loaded
38 add_action( 'after_setup_theme', 'themify_builder_themify_dependencies',1 );
39 add_action( 'after_setup_theme', 'themify_builder_plugin_init', 2 );
40 add_filter( 'plugin_row_meta', 'themify_builder_plugin_meta', 10, 2 );
41 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'themify_builder_action_links' );
42
43
44 if ( ! function_exists( 'themify_builder_activate' ) ) {
45 /**
46 * Plugin activation
47 *
48 * This runs only when Builder plugin is activated.
49 */
50 function themify_builder_activate() {
51 flush_rewrite_rules();
52 }
53 }
54 register_activation_hook( __FILE__, 'themify_builder_activate' );
55
56 if(!function_exists('themify_builder_plugin_meta')){
57 function themify_builder_plugin_meta( $links, $file ) {
58 if ( plugin_basename( __FILE__ ) === $file ) {
59 $row_meta = array(
60 'changelogs' => '<a href="' . esc_url( 'https://themify.me/changelogs/' ) . basename( dirname( $file ) ) .'.txt" target="_blank" aria-label="' . esc_attr__( 'Plugin Changelogs', 'themify' ) . '">' . esc_html__( 'View Changelogs', 'themify' ) . '</a>'
61 );
62
63 return array_merge( $links, $row_meta );
64 }
65 return (array) $links;
66 }
67 }
68 if(!function_exists('themify_builder_action_links')){
69 function themify_builder_action_links( $links ) {
70 if ( is_plugin_active( 'themify-updater/themify-updater.php' ) ) {
71 $tlinks = array(
72 '<a href="' . admin_url( 'index.php?page=themify-license' ) . '">'.__('Themify License', 'themify') .'</a>',
73 );
74 } else {
75 $tlinks = array(
76 '<a href="' . esc_url('https://themify.me/docs/themify-updater-documentation') . '">'. __('Themify Updater', 'themify') .'</a>',
77 );
78 }
79 return array_merge( $links, $tlinks );
80 }
81 }
82
83 ///////////////////////////////////////////
84 // Version Getter
85 ///////////////////////////////////////////
86 if (!function_exists('themify_builder_get')) {
87
88 function themify_builder_get(string $theme_var, $builder_var = false,bool $data_only=true) {
89 static $is=null;
90 if($is===null){
91 $is=\themify_is_themify_theme();
92 }
93 if ($is===true) {
94 return \themify_get($theme_var,null,$data_only);
95 }
96 if ($builder_var === false) {
97 return false;
98 }
99 global $post;
100 $data = \Themify_Builder_Model::get_builder_settings();
101 if (isset($data[$builder_var]) && $data[$builder_var] !== '') {
102 return $data[$builder_var];
103 }
104 elseif (isset($post) && ($val = \get_post_meta($post->ID, $builder_var, true)) !== '') {
105 return $val;
106 }
107 return null;
108 }
109
110 }
111 if ( ! function_exists( 'themify_builder_check' ) ) {
112
113 function themify_builder_check(string $theme_var, $builder_var = false, bool $data_only = true ):bool {
114 $val = \themify_builder_get( $theme_var, $builder_var, $data_only );
115
116 return $val !== null && $val !== '' && $val !== 'off';
117 }
118
119 }
120 if(!function_exists('themify_builder_themify_dependencies')){
121 /**
122 * Load themify functions
123 */
124 function themify_builder_themify_dependencies(){
125 if ( class_exists( 'Themify_Builder',false ) ) return;
126
127 if ( ! defined( 'THEMIFY_DIR' ) ) {
128 /**
129 * Force regenerate the Builder CSS file after an update
130 */
131 //
132 define( 'THEMIFY_BUILDER_REGENERATE_CSS', true );
133 $path = plugin_dir_path( __FILE__ ) ;
134 define( 'THEMIFY_VERSION', '7.7.1' );
135 define( 'THEMIFY_DIR', $path. 'themify' );
136 define( 'THEMIFY_URI', plugin_dir_url( __FILE__ ) . 'themify' );
137 require_once THEMIFY_DIR . '/themify-database.php';
138 require_once THEMIFY_DIR . '/class-themify-get-image-size.php';
139 require_once THEMIFY_DIR . '/img.php' ;
140 require_once THEMIFY_DIR . '/themify-utils.php';
141 require_once THEMIFY_DIR . '/themify-fw-filters.php';
142 require_once THEMIFY_DIR . '/themify-hooks.php';
143 require_once $path. 'theme-options.php';
144 if( is_admin() ) {
145 require_once THEMIFY_DIR . '/themify-wpajax.php';
146 }
147 if( ! class_exists( 'Themify_Metabox',false ) ) {
148 require_once $path. 'themify/themify-metabox/themify-metabox.php';
149 }
150 }
151
152 require_once THEMIFY_DIR . '/google-fonts/functions.php';
153
154 if( ! function_exists( 'themify_get_featured_image_link' ) ) {
155 require_once THEMIFY_DIR . '/themify-template-tags.php';
156 }
157
158 require_once THEMIFY_DIR . '/themify-icon-picker/themify-icon-font.php';
159 }
160 }
161
162 // register additional field types used by Builder
163 add_action( 'themify_metabox/field/page_builder', 'themify_meta_field_page_builder', 10, 1 );
164 add_action( 'themify_metabox/field/fontawesome', 'themify_meta_field_fontawesome', 10, 1 );
165 add_action( 'themify_metabox/field/query_category', 'themify_meta_field_query_category', 10, 1 );
166 add_action( 'themify_metabox/field/featimgdropdown', 'themify_meta_field_featimgdropdown', 10, 1 );
167
168 if ( ! function_exists( 'themify_builder_plugin_init' ) ){
169
170 if(!function_exists('theme_compatibility')){
171 function themify_builder_theme_compatibility(){
172 $dir=THEMIFY_BUILDER_DIR . '/theme-compat/' . get_template() ;
173 if ( is_file( $dir . '.css' ) ) {
174 add_theme_support( 'themify-page-options' );
175 }
176 $theme_compatibility_file = $dir. '.php';
177 if ( is_file( $theme_compatibility_file ) ) {
178 include $theme_compatibility_file;
179 }
180 }
181 }
182 /**
183 * Init Plugin
184 * called after theme to avoid redeclare function error
185 */
186 function themify_builder_plugin_init() {
187 if ( class_exists('Themify_Builder',false) ) return;
188
189
190 /**
191 * Define builder constant
192 */
193 $path=plugin_basename( __FILE__);
194 define( 'THEMIFY_BUILDER_NAME', trim( dirname( $path ), '/' ) );
195 define( 'THEMIFY_BUILDER_SLUG', trim( $path, '/' ) );
196
197
198 // File Path
199 define( 'THEMIFY_BUILDER_DIR', __DIR__ );
200 define( 'THEMIFY_BUILDER_MODULES_DIR', THEMIFY_BUILDER_DIR . '/modules' );
201 define( 'THEMIFY_BUILDER_TEMPLATES_DIR', THEMIFY_BUILDER_DIR . '/templates' );
202 define( 'THEMIFY_BUILDER_CLASSES_DIR', THEMIFY_BUILDER_DIR . '/classes' );
203 define( 'THEMIFY_BUILDER_INCLUDES_DIR', THEMIFY_BUILDER_DIR . '/includes' );
204
205 // URI Constant
206 define( 'THEMIFY_BUILDER_URI', plugins_url( '' , __FILE__ ) );
207 define('THEMIFY_BUILDER_CSS_MODULES', THEMIFY_BUILDER_URI . '/css/modules/');
208 define('THEMIFY_BUILDER_JS_MODULES', THEMIFY_BUILDER_URI . '/js/modules/');
209
210 // Load Localization
211 load_plugin_textdomain( 'themify', false, THEMIFY_BUILDER_NAME . '/languages' );
212 // Include files
213 require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-model.php';
214 require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-layouts.php';
215 require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-global-styles.php';
216 require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder.php';
217 require THEMIFY_BUILDER_DIR . '/plugin/classes/class-themify-builder-settings.php';
218 require_once THEMIFY_DIR .'/class-themify-storage.php';
219 require_once THEMIFY_DIR . '/cache/class-themify-cache.php';
220 require_once THEMIFY_DIR . '/class-themify-enqueue.php';
221 require_once THEMIFY_DIR . '/class-themify-access-role.php';
222 require_once THEMIFY_DIR . '/class-themify-filesystem.php';
223 require_once THEMIFY_DIR . '/class-themify-custom-fonts.php';
224 require_once THEMIFY_DIR . '/class-tf-sv.php';
225 require_once THEMIFY_DIR . '/class-themify-maintenance-mode.php';
226 require_once THEMIFY_BUILDER_DIR . '/plugin/classes/class-themify-builder-page-options.php';
227
228 if ( Themify_Builder_Model::builder_check() ) {
229
230 global $ThemifyBuilder;//deprecated
231 do_action( 'themify_builder_before_init' );
232 $ThemifyBuilder = new Themify_Builder();//deprecated
233 add_action( 'init', array( 'Themify_Builder','init' ), 0 );
234 themify_builder_theme_compatibility();
235 }
236
237 if( is_admin() ){
238 require_once THEMIFY_DIR . '/themify-admin.php';
239 require_once THEMIFY_DIR . '/themify-status.php';
240 }
241
242 /* enables the Page Options to be edited from frontend, only for Page post-type */
243 add_theme_support( 'frontend-page-options', [ 'page' ] );
244 }
245 }
246 if ( ! function_exists('themify_builder_edit_module_panel') ) {
247 /**
248 * Hook edit module frontend panel
249 * @param $mod_name
250 * @param $mod_settings
251 */
252 function themify_builder_edit_module_panel( $mod_name, $mod_settings ) {
253 do_action( 'themify_builder_edit_module_panel', $mod_name, $mod_settings );
254 }
255 }
256