| 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.7 |
| 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 |
if ( ! \class_exists( 'Themify_Builder_Model', false ) ) { |
| 100 |
return null; |
| 101 |
} |
| 102 |
global $post; |
| 103 |
$data = \Themify_Builder_Model::get_builder_settings(); |
| 104 |
if (isset($data[$builder_var]) && $data[$builder_var] !== '') { |
| 105 |
return $data[$builder_var]; |
| 106 |
} |
| 107 |
elseif (isset($post) && ($val = \get_post_meta($post->ID, $builder_var, true)) !== '') { |
| 108 |
return $val; |
| 109 |
} |
| 110 |
return null; |
| 111 |
} |
| 112 |
|
| 113 |
} |
| 114 |
if ( ! function_exists( 'themify_builder_check' ) ) { |
| 115 |
|
| 116 |
function themify_builder_check(string $theme_var, $builder_var = false, bool $data_only = true ):bool { |
| 117 |
$val = \themify_builder_get( $theme_var, $builder_var, $data_only ); |
| 118 |
|
| 119 |
return $val !== null && $val !== '' && $val !== 'off'; |
| 120 |
} |
| 121 |
|
| 122 |
} |
| 123 |
if(!function_exists('themify_builder_themify_dependencies')){ |
| 124 |
/** |
| 125 |
* Load themify functions |
| 126 |
*/ |
| 127 |
function themify_builder_themify_dependencies(){ |
| 128 |
if ( class_exists( 'Themify_Builder',false ) ) return; |
| 129 |
|
| 130 |
if ( ! defined( 'THEMIFY_DIR' ) ) { |
| 131 |
/** |
| 132 |
* Force regenerate the Builder CSS file after an update |
| 133 |
*/ |
| 134 |
// |
| 135 |
define( 'THEMIFY_BUILDER_REGENERATE_CSS', true ); |
| 136 |
$path = plugin_dir_path( __FILE__ ) ; |
| 137 |
define( 'THEMIFY_VERSION', '7.7.7' ); |
| 138 |
define( 'THEMIFY_DIR', $path. 'themify' ); |
| 139 |
define( 'THEMIFY_URI', plugin_dir_url( __FILE__ ) . 'themify' ); |
| 140 |
require_once THEMIFY_DIR . '/themify-database.php'; |
| 141 |
require_once THEMIFY_DIR . '/class-themify-get-image-size.php'; |
| 142 |
require_once THEMIFY_DIR . '/img.php' ; |
| 143 |
require_once THEMIFY_DIR . '/themify-utils.php'; |
| 144 |
require_once THEMIFY_DIR . '/themify-fw-filters.php'; |
| 145 |
require_once THEMIFY_DIR . '/themify-hooks.php'; |
| 146 |
require_once $path. 'theme-options.php'; |
| 147 |
if( is_admin() ) { |
| 148 |
require_once THEMIFY_DIR . '/themify-wpajax.php'; |
| 149 |
} |
| 150 |
if( ! class_exists( 'Themify_Metabox',false ) ) { |
| 151 |
require_once $path. 'themify/themify-metabox/themify-metabox.php'; |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
require_once THEMIFY_DIR . '/google-fonts/functions.php'; |
| 156 |
|
| 157 |
if( ! function_exists( 'themify_get_featured_image_link' ) ) { |
| 158 |
require_once THEMIFY_DIR . '/themify-template-tags.php'; |
| 159 |
} |
| 160 |
|
| 161 |
require_once THEMIFY_DIR . '/themify-icon-picker/themify-icon-font.php'; |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
// register additional field types used by Builder |
| 166 |
add_action( 'themify_metabox/field/page_builder', 'themify_meta_field_page_builder', 10, 1 ); |
| 167 |
add_action( 'themify_metabox/field/fontawesome', 'themify_meta_field_fontawesome', 10, 1 ); |
| 168 |
add_action( 'themify_metabox/field/query_category', 'themify_meta_field_query_category', 10, 1 ); |
| 169 |
add_action( 'themify_metabox/field/featimgdropdown', 'themify_meta_field_featimgdropdown', 10, 1 ); |
| 170 |
|
| 171 |
if ( ! function_exists( 'themify_builder_plugin_init' ) ){ |
| 172 |
|
| 173 |
if(!function_exists('theme_compatibility')){ |
| 174 |
function themify_builder_theme_compatibility(){ |
| 175 |
$dir=THEMIFY_BUILDER_DIR . '/theme-compat/' . get_template() ; |
| 176 |
if ( is_file( $dir . '.css' ) ) { |
| 177 |
add_theme_support( 'themify-page-options' ); |
| 178 |
} |
| 179 |
$theme_compatibility_file = $dir. '.php'; |
| 180 |
if ( is_file( $theme_compatibility_file ) ) { |
| 181 |
include $theme_compatibility_file; |
| 182 |
} |
| 183 |
} |
| 184 |
} |
| 185 |
/** |
| 186 |
* Init Plugin |
| 187 |
* called after theme to avoid redeclare function error |
| 188 |
*/ |
| 189 |
function themify_builder_plugin_init() { |
| 190 |
if ( class_exists('Themify_Builder',false) ) return; |
| 191 |
|
| 192 |
|
| 193 |
/** |
| 194 |
* Define builder constant |
| 195 |
*/ |
| 196 |
$path=plugin_basename( __FILE__); |
| 197 |
define( 'THEMIFY_BUILDER_NAME', trim( dirname( $path ), '/' ) ); |
| 198 |
define( 'THEMIFY_BUILDER_SLUG', trim( $path, '/' ) ); |
| 199 |
|
| 200 |
|
| 201 |
// File Path |
| 202 |
define( 'THEMIFY_BUILDER_DIR', __DIR__ ); |
| 203 |
define( 'THEMIFY_BUILDER_MODULES_DIR', THEMIFY_BUILDER_DIR . '/modules' ); |
| 204 |
define( 'THEMIFY_BUILDER_TEMPLATES_DIR', THEMIFY_BUILDER_DIR . '/templates' ); |
| 205 |
define( 'THEMIFY_BUILDER_CLASSES_DIR', THEMIFY_BUILDER_DIR . '/classes' ); |
| 206 |
define( 'THEMIFY_BUILDER_INCLUDES_DIR', THEMIFY_BUILDER_DIR . '/includes' ); |
| 207 |
|
| 208 |
// URI Constant |
| 209 |
define( 'THEMIFY_BUILDER_URI', plugins_url( '' , __FILE__ ) ); |
| 210 |
define('THEMIFY_BUILDER_CSS_MODULES', THEMIFY_BUILDER_URI . '/css/modules/'); |
| 211 |
define('THEMIFY_BUILDER_JS_MODULES', THEMIFY_BUILDER_URI . '/js/modules/'); |
| 212 |
|
| 213 |
// Load Localization |
| 214 |
load_plugin_textdomain( 'themify', false, THEMIFY_BUILDER_NAME . '/languages' ); |
| 215 |
// Include files |
| 216 |
require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-model.php'; |
| 217 |
require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-layouts.php'; |
| 218 |
require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-global-styles.php'; |
| 219 |
require THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder.php'; |
| 220 |
require THEMIFY_BUILDER_DIR . '/plugin/classes/class-themify-builder-settings.php'; |
| 221 |
require_once THEMIFY_DIR .'/class-themify-storage.php'; |
| 222 |
require_once THEMIFY_DIR . '/cache/class-themify-cache.php'; |
| 223 |
if ( ! function_exists( 'themify_wc_get_script_handle' ) |
| 224 |
&& function_exists( 'themify_is_woocommerce_active' ) && themify_is_woocommerce_active() ) { |
| 225 |
require_once THEMIFY_DIR . '/plugin-compat/woocommerce.php'; |
| 226 |
} |
| 227 |
require_once THEMIFY_DIR . '/class-themify-enqueue.php'; |
| 228 |
require_once THEMIFY_DIR . '/class-themify-access-role.php'; |
| 229 |
require_once THEMIFY_DIR . '/class-themify-filesystem.php'; |
| 230 |
require_once THEMIFY_DIR . '/class-themify-custom-fonts.php'; |
| 231 |
require_once THEMIFY_DIR . '/class-tf-sv.php'; |
| 232 |
require_once THEMIFY_DIR . '/class-themify-maintenance-mode.php'; |
| 233 |
require_once THEMIFY_BUILDER_DIR . '/plugin/classes/class-themify-builder-page-options.php'; |
| 234 |
|
| 235 |
if ( Themify_Builder_Model::builder_check() ) { |
| 236 |
|
| 237 |
global $ThemifyBuilder;//deprecated |
| 238 |
do_action( 'themify_builder_before_init' ); |
| 239 |
$ThemifyBuilder = new Themify_Builder();//deprecated |
| 240 |
add_action( 'init', array( 'Themify_Builder','init' ), 0 ); |
| 241 |
/* Must register before WPML PB Loader runs (init priority -35). */ |
| 242 |
add_action( 'wpml_load_page_builders_integration', [ 'Themify_Builder', 'wpml_load_page_builders_integration' ] ); |
| 243 |
themify_builder_theme_compatibility(); |
| 244 |
} |
| 245 |
|
| 246 |
if( is_admin() ){ |
| 247 |
require_once THEMIFY_DIR . '/themify-admin.php'; |
| 248 |
require_once THEMIFY_DIR . '/themify-status.php'; |
| 249 |
} |
| 250 |
|
| 251 |
/* enables the Page Options to be edited from frontend, only for Page post-type */ |
| 252 |
add_theme_support( 'frontend-page-options', [ 'page' ] ); |
| 253 |
} |
| 254 |
} |
| 255 |
if ( ! function_exists('themify_builder_edit_module_panel') ) { |
| 256 |
/** |
| 257 |
* Hook edit module frontend panel |
| 258 |
* @param $mod_name |
| 259 |
* @param $mod_settings |
| 260 |
*/ |
| 261 |
function themify_builder_edit_module_panel( $mod_name, $mod_settings ) { |
| 262 |
do_action( 'themify_builder_edit_module_panel', $mod_name, $mod_settings ); |
| 263 |
} |
| 264 |
} |
| 265 |
|