| @@ -1,20 +1,34 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | -Plugin Name: SpiceBox | |
| 4 | -Plugin URI: | |
| 5 | -Description: Enhances Spicethemes with extra functionality. | |
| 6 | -Version: 0.2.2 | |
| 7 | -Author: Spicethemes | |
| 8 | -Author URI: https://github.com | |
| 9 | -Text Domain: spicebox | |
| 3 | +Plugin Name: SpiceBox | |
| 4 | +Description: Enhances SpiceThemes with extra functionality. | |
| 5 | +Version: 2.4 | |
| 6 | +Requires at least: 3.3 | |
| 7 | +Requires PHP: 5.2 | |
| 8 | +Tested up to: 6.7.1 | |
| 9 | +Author: Spicethemes | |
| 10 | +Author URI: https://spicethemes.com | |
| 11 | +License: GPLv2 or later | |
| 12 | +License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
| 13 | +Text Domain: spicebox | |
| 14 | +Domain Path: /languages | |
| 10 | 15 | */ |
| 11 | 16 | define( 'SPICEB_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 12 | 17 | define( 'SPICEB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 13 | 18 | |
| 19 | +// Assuming WC_PLUGIN_VERSION is defined somewhere in your plugin | |
| 20 | +if ( ! defined( 'SPICEBOX_PLUGIN_VERSION' ) ) { | |
| 21 | + define( 'SPICEBOX_PLUGIN_VERSION', '2.4' ); | |
| 22 | +} | |
| 23 | + | |
| 14 | 24 | function spiceb_activate() { |
| 15 | 25 | $theme = wp_get_theme(); // gets the current theme |
| 16 | - if ( 'SpicePress' == $theme->name ){ | |
| 26 | + if ( 'SpicePress' == $theme->name || 'SpicePress Dark' == $theme->name || 'Rockers' == $theme->name || 'Content' == $theme->name || 'Certify' == $theme->name || 'Stacy' == $theme->name || 'SpicePress Child Theme' == $theme->name || 'SpicePress Child' == $theme->name){ | |
| 27 | + | |
| 28 | + //Alpha Color Control | |
| 29 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 30 | + require_once('inc/controls/customizer-image-radio-button/image_radio_button.php'); | |
| 17 | 31 | require_once('inc/spicepress/features/feature-slider-section.php'); |
| 18 | 32 | require_once('inc/spicepress/features/feature-service-section.php'); |
| 19 | 33 | require_once('inc/spicepress/features/feature-portfolio-section.php'); |
| 20 | 34 | require_once('inc/spicepress/features/feature-testimonial-section.php'); |
| @@ -22,49 +36,701 @@ | ||
| 22 | 36 | require_once('inc/spicepress/sections/spicepress-features-section.php'); |
| 23 | 37 | require_once('inc/spicepress/sections/spicepress-portfolio-section.php'); |
| 24 | 38 | require_once('inc/spicepress/sections/spicepress-testimonail-section.php'); |
| 25 | 39 | require_once('inc/spicepress/customizer.php'); |
| 40 | + } | |
| 41 | + | |
| 42 | + if ( 'HoneyPress' == $theme->name || 'HoneyPress Child' == $theme->name || 'Radix Multipurpose' == $theme->name || 'HoneyWaves' == $theme->name || 'Bizhunt' == $theme->name || 'Tromas' == $theme->name || 'HoneyBee' == $theme->name || 'Honeypress Dark' == $theme->name ){ | |
| 43 | + require_once('inc/honeypress/features/feature-slider-section.php'); | |
| 44 | + require_once('inc/honeypress/features/feature-service-section.php'); | |
| 45 | + require_once('inc/honeypress/features/feature-testimonial-section.php'); | |
| 46 | + require_once('inc/honeypress/sections/honeypress-slider-section.php'); | |
| 47 | + require_once('inc/honeypress/sections/honeypress-service-section.php'); | |
| 48 | + require_once('inc/honeypress/sections/honeypress-testimonail-section.php'); | |
| 49 | + require_once('inc/honeypress/customizer.php'); | |
| 50 | + } | |
| 51 | + if ( 'CloudPress' == $theme->name || 'CloudPress Child' == $theme->name || 'CloudPress Dark' == $theme->name || 'CloudPress Agency' == $theme->name || 'CloudPress Business' == $theme->name){ | |
| 52 | + require_once('inc/cloudpress/features/feature-slider-section.php'); | |
| 53 | + require_once('inc/cloudpress/features/feature-cta-section.php'); | |
| 54 | + require_once('inc/cloudpress/features/feature-service-section.php'); | |
| 55 | + require_once('inc/cloudpress/features/feature-funfact-section.php'); | |
| 56 | + require_once('inc/cloudpress/features/feature-team-section.php'); | |
| 57 | + require_once('inc/cloudpress/sections/cloudpress-slider-section.php'); | |
| 58 | + require_once('inc/cloudpress/sections/cloudpress-cta-section.php'); | |
| 59 | + require_once('inc/cloudpress/sections/cloudpress-service-section.php'); | |
| 60 | + require_once('inc/cloudpress/sections/cloudpress-funfact-section.php'); | |
| 61 | + require_once('inc/cloudpress/sections/cloudpress-team-section.php'); | |
| 62 | + require_once('inc/cloudpress/customizer.php'); | |
| 63 | + } | |
| 64 | + | |
| 65 | + if ( 'CloudPress Dark' == $theme->name || 'CloudPress Agency' == $theme->name || 'CloudPress Business' == $theme->name){ | |
| 66 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 67 | + require_once('inc/cloudpress/features/feature-testimonial-section.php'); | |
| 68 | + require_once('inc/cloudpress/sections/cloudpress-testimonail-section.php'); | |
| 69 | + } | |
| 70 | + | |
| 71 | + if ( 'Chilly' == $theme->name || 'SpiceBlue' == $theme->name){ | |
| 72 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 73 | + require_once('inc/spicepress/features/feature-service-section.php'); | |
| 74 | + require_once('inc/spicepress/features/feature-portfolio-section.php'); | |
| 75 | + require_once('inc/spicepress/features/feature-testimonial-section.php'); | |
| 76 | + require_once('inc/spicepress/sections/spicepress-features-section.php'); | |
| 77 | + require_once('inc/spicepress/sections/spicepress-portfolio-section.php'); | |
| 78 | + require_once('inc/spicepress/sections/spicepress-testimonail-section.php'); | |
| 79 | + require_once('inc/spicepress/customizer.php'); | |
| 80 | + } | |
| 81 | + | |
| 82 | + if ( 'Innofit' == $theme->name || 'Innofit Child' == $theme->name){ | |
| 83 | + | |
| 84 | + | |
| 85 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 86 | + | |
| 87 | + | |
| 88 | + if ( ! is_plugin_active( 'innofit-plus/innofit-plus.php' ) ): | |
| 89 | + | |
| 90 | + | |
| 91 | + if ( ! function_exists( 'spiceb_innofit_customize_register' ) ) : | |
| 92 | + function spiceb_innofit_customize_register($wp_customize){ | |
| 93 | + | |
| 94 | + | |
| 95 | + if(!empty(get_theme_mod('innofit_testimonial_content'))) | |
| 96 | + { | |
| 97 | + $sections_customizer_data = array('slider','services','about','testimonial','team','news','callout','contact','subscriber','wooproduct'); | |
| 98 | + } | |
| 99 | + else | |
| 100 | + { | |
| 101 | + $sections_customizer_data = array('slider','services','about','team','news','callout','contact','subscriber','wooproduct'); | |
| 102 | + } | |
| 103 | + | |
| 104 | + if(!empty(get_theme_mod('home_call_out_title'))) | |
| 105 | + { | |
| 106 | + $sections_customizer_data = array('slider','services','about','testimonial','team','news','callout','contact','subscriber','wooproduct'); | |
| 107 | + } | |
| 108 | + else | |
| 109 | + { | |
| 110 | + $sections_customizer_data = array('slider','services','about','team','news','contact','subscriber','wooproduct'); | |
| 111 | + } | |
| 112 | + | |
| 113 | + | |
| 114 | + if(!empty(get_theme_mod('innofit_subscribe_title'))) | |
| 115 | + { | |
| 116 | + $sections_customizer_data = array('slider','services','about','testimonial','team','news','callout','contact','subscriber','wooproduct'); | |
| 117 | + } | |
| 118 | + else | |
| 119 | + { | |
| 120 | + $sections_customizer_data = array('slider','services','about','team','news','contact','wooproduct'); | |
| 121 | + } | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; | |
| 128 | + | |
| 129 | + if (!empty($sections_customizer_data)) | |
| 130 | + { | |
| 131 | + foreach($sections_customizer_data as $section_customizer_data) | |
| 132 | + { | |
| 133 | + require_once('inc/innofit/customizer/'.$section_customizer_data.'-section.php'); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + $wp_customize->remove_control('header_textcolor'); | |
| 137 | + | |
| 138 | + } | |
| 139 | + add_action( 'customize_register', 'spiceb_innofit_customize_register' ); | |
| 140 | + endif; | |
| 141 | + | |
| 142 | + | |
| 143 | + $sections_data = array('slider','services','about','testimonial','team','news','callout','contact','subscriber','wooproduct'); | |
| 144 | + | |
| 145 | + if (!empty($sections_data)) | |
| 146 | + { | |
| 147 | + foreach($sections_data as $section_data) | |
| 148 | + { | |
| 149 | + require_once('inc/innofit/sections/innofit-'.$section_data.'-section.php'); | |
| 150 | + } | |
| 151 | + } | |
| 152 | + | |
| 153 | + require_once('inc/innofit/customizer/customizer-render-callbacks.php'); | |
| 154 | + require_once('inc/innofit/customizer.php'); | |
| 155 | + | |
| 156 | + | |
| 157 | + endif; | |
| 158 | + | |
| 159 | + } | |
| 160 | + | |
| 161 | + if ( 'BusiCare' == $theme->name || 'BusiCare Child' == $theme->name || 'BusiCare Dark' == $theme->name){ | |
| 26 | 162 | |
| 163 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 164 | + | |
| 165 | + if ( ! is_plugin_active( 'busicare-plus/busicare-plus.php' ) ): | |
| 166 | + | |
| 167 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 168 | + require_once('inc/controls/customizer-repeater/functions.php'); | |
| 169 | + require ('inc/controls/customizer-text-radio/customizer-text-radio.php'); | |
| 170 | + | |
| 171 | + if ( ! function_exists( 'spiceb_busicare_customize_register' ) ) : | |
| 172 | + function spiceb_busicare_customize_register($wp_customize){ | |
| 173 | + | |
| 174 | + $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; | |
| 175 | + $sections_customizer_data = array('slider','services','news','testimonial','team'); | |
| 176 | + | |
| 177 | + if (!empty($sections_customizer_data)) | |
| 178 | + { | |
| 179 | + foreach($sections_customizer_data as $section_customizer_data) | |
| 180 | + { | |
| 181 | + require_once('inc/busicare/customizer/'.$section_customizer_data.'-section.php'); | |
| 182 | + } | |
| 183 | + } | |
| 184 | + $wp_customize->remove_control('header_textcolor'); | |
| 185 | + | |
| 186 | + } | |
| 187 | + add_action( 'customize_register', 'spiceb_busicare_customize_register' ); | |
| 188 | + endif; | |
| 189 | + | |
| 190 | + if ( 'BusiCare' == $theme->name || 'BusiCare Child' == $theme->name) | |
| 191 | + { | |
| 192 | + $sections_data = array('slider','services','news','testimonial','team'); | |
| 193 | + } | |
| 194 | + else | |
| 195 | + { | |
| 196 | + $sections_data = array('slider','services','news-dark','testimonial','team'); | |
| 197 | + } | |
| 198 | + | |
| 199 | + if (!empty($sections_data)){ | |
| 200 | + | |
| 201 | + foreach($sections_data as $section_data){ | |
| 202 | + require_once('inc/busicare/sections/busicare-'.$section_data.'-section.php'); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + | |
| 206 | + require_once('inc/busicare/customizer.php'); | |
| 207 | + | |
| 208 | + endif; | |
| 27 | 209 | } |
| 28 | 210 | |
| 211 | + //Spice Software | |
| 212 | + if ( 'Spice Software' == $theme->name || 'Spice Software Dark' == $theme->name || 'Spice Software Child' == $theme->name){ | |
| 213 | + | |
| 214 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 215 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 216 | + if ( ! is_plugin_active( 'spice-software-plus/spice-software-plus.php' ) ): | |
| 217 | + | |
| 218 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 219 | + require_once('inc/controls/customizer-repeater/functions.php'); | |
| 220 | + require ('inc/controls/customizer-text-radio/customizer-text-radio.php'); | |
| 221 | + | |
| 222 | + if ( ! function_exists( 'spiceb_spice_software_customize_register' ) ) : | |
| 223 | + function spiceb_spice_software_customize_register($wp_customize){ | |
| 224 | + | |
| 225 | + $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; | |
| 226 | + $sections_customizer_data = array('slider','services','news','testimonial','team'); | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + if (!empty($sections_customizer_data)) | |
| 231 | + { | |
| 232 | + foreach($sections_customizer_data as $section_customizer_data) | |
| 233 | + { | |
| 234 | + require_once('inc/spice-software/customizer/'.$section_customizer_data.'-section.php'); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + $wp_customize->remove_control('header_textcolor'); | |
| 238 | + | |
| 239 | + } | |
| 240 | + add_action( 'customize_register', 'spiceb_spice_software_customize_register' ); | |
| 241 | + endif; | |
| 242 | + | |
| 243 | + $sections_data = array('slider','services','news','testimonial','team'); | |
| 244 | + | |
| 245 | + if (!empty($sections_data)){ | |
| 246 | + | |
| 247 | + foreach($sections_data as $section_data){ | |
| 248 | + require_once('inc/spice-software/sections/spice-software-'.$section_data.'-section.php'); | |
| 249 | + } | |
| 250 | + } | |
| 251 | + | |
| 252 | + require_once('inc/spice-software/customizer.php'); | |
| 253 | + | |
| 254 | + endif; | |
| 255 | + } | |
| 256 | + | |
| 257 | + | |
| 258 | + //Spiko | |
| 259 | + if ( 'Spiko' == $theme->name || 'Spiko Child' == $theme->name || 'Spiko Dark' == $theme->name){ | |
| 260 | + | |
| 261 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 262 | + | |
| 263 | + if ( ! is_plugin_active( 'spiko-plus/spiko-plus.php' ) ): | |
| 264 | + | |
| 265 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 266 | + require_once('inc/controls/customizer-repeater/functions.php'); | |
| 267 | + require ('inc/controls/customizer-text-radio/customizer-text-radio.php'); | |
| 268 | + | |
| 269 | + if ( ! function_exists( 'spiceb_spiko_customize_register' ) ) : | |
| 270 | + function spiceb_spiko_customize_register($wp_customize){ | |
| 271 | + | |
| 272 | + $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; | |
| 273 | + $sections_customizer_data = array('slider','services','testimonial','team','news'); | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + if (!empty($sections_customizer_data)) | |
| 278 | + { | |
| 279 | + foreach($sections_customizer_data as $section_customizer_data) | |
| 280 | + { | |
| 281 | + require_once('inc/spiko/customizer/'.$section_customizer_data.'-section.php'); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + $wp_customize->remove_control('header_textcolor'); | |
| 285 | + | |
| 286 | + } | |
| 287 | + add_action( 'customize_register', 'spiceb_spiko_customize_register' ); | |
| 288 | + endif; | |
| 289 | + | |
| 290 | + $sections_data = array('slider','services','testimonial','team','news'); | |
| 291 | + | |
| 292 | + if (!empty($sections_data)){ | |
| 293 | + | |
| 294 | + foreach($sections_data as $section_data){ | |
| 295 | + require_once('inc/spiko/sections/spiko-'.$section_data.'-section.php'); | |
| 296 | + } | |
| 297 | + } | |
| 298 | + | |
| 299 | + require_once('inc/spiko/customizer.php'); | |
| 300 | + | |
| 301 | + endif; | |
| 302 | + } | |
| 303 | + | |
| 304 | +//WPKites | |
| 305 | + if ( 'WPKites' == $theme->name || 'WPKites Child' == $theme->name || 'WPKites Dark' == $theme->name){ | |
| 306 | + | |
| 307 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 308 | + | |
| 309 | + if ( ! is_plugin_active( 'wpkites-plus/wpkites-plus.php' ) ): | |
| 310 | + | |
| 311 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 312 | + require_once('inc/controls/customizer-repeater/functions.php'); | |
| 313 | + require ('inc/controls/customizer-text-radio/customizer-text-radio.php'); | |
| 314 | + | |
| 315 | + if ( ! function_exists( 'spiceb_wpkites_customize_register' ) ) : | |
| 316 | + function spiceb_wpkites_customize_register($wp_customize){ | |
| 317 | + | |
| 318 | + $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; | |
| 319 | + $sections_customizer_data = array('slider','services','team','news','testimonial'); | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + if (!empty($sections_customizer_data)) | |
| 324 | + { | |
| 325 | + foreach($sections_customizer_data as $section_customizer_data) | |
| 326 | + { | |
| 327 | + require_once('inc/wpkites/customizer/'.$section_customizer_data.'-section.php'); | |
| 328 | + } | |
| 329 | + } | |
| 330 | + $wp_customize->remove_control('header_textcolor'); | |
| 331 | + | |
| 332 | + } | |
| 333 | + add_action( 'customize_register', 'spiceb_wpkites_customize_register' ); | |
| 334 | + endif; | |
| 335 | + | |
| 336 | + $sections_data = array('slider','services','team','news','testimonial'); | |
| 337 | + | |
| 338 | + if (!empty($sections_data)){ | |
| 339 | + | |
| 340 | + foreach($sections_data as $section_data){ | |
| 341 | + require_once('inc/wpkites/sections/wpkites-'.$section_data.'-section.php'); | |
| 342 | + } | |
| 343 | + } | |
| 344 | + | |
| 345 | + require_once('inc/wpkites/customizer.php'); | |
| 346 | + | |
| 347 | + endif; | |
| 348 | + | |
| 349 | + | |
| 350 | + add_action( 'admin_menu', 'wpkites_starter_sites_menu',999 ); | |
| 351 | + if(!function_exists('wpkites_starter_sites_menu')) { | |
| 352 | + function wpkites_starter_sites_menu() { | |
| 353 | + | |
| 354 | + add_submenu_page( | |
| 355 | + 'wpkites-panel', | |
| 356 | + esc_html__( 'Starer Sites', 'spicebox' ), | |
| 357 | + esc_html__( 'Starer Sites', 'spicebox' ), | |
| 358 | + 'manage_options', | |
| 359 | + 'starter-sites', | |
| 360 | + function() { require_once SPICEB_PLUGIN_DIR.'inc/wpkites/starter-sites/view.php'; }, | |
| 361 | + 2 | |
| 362 | + ); | |
| 363 | + | |
| 364 | + add_submenu_page( | |
| 365 | + 'wpkites-panel', | |
| 366 | + esc_html__( 'Extensions', 'spicebox' ), | |
| 367 | + esc_html__( 'Extensions', 'spicebox' ), | |
| 368 | + 'manage_options', | |
| 369 | + 'extensions', | |
| 370 | + function() { require_once SPICEB_PLUGIN_DIR.'inc/wpkites/extensions/view.php'; }, | |
| 371 | + 2 | |
| 372 | + ); | |
| 373 | + | |
| 374 | + } | |
| 375 | + | |
| 376 | + } | |
| 377 | + } | |
| 378 | + | |
| 379 | +//WPHester | |
| 380 | + if ( 'WPHester' == $theme->name || 'WPHester Child' == $theme->name || 'WPHester Dark' == $theme->name){ | |
| 381 | + | |
| 382 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 383 | + | |
| 384 | + if ( ! is_plugin_active( 'wphester-plus/wphester-plus.php' ) ): | |
| 385 | + | |
| 386 | + require_once('inc/controls/customizer-alpha-color-picker/class-spicepress-customize-alpha-color-control.php'); | |
| 387 | + require_once('inc/controls/customizer-repeater/functions.php'); | |
| 388 | + require ('inc/controls/customizer-text-radio/customizer-text-radio.php'); | |
| 389 | + | |
| 390 | + if ( ! function_exists( 'spiceb_wphester_customize_register' ) ) : | |
| 391 | + function spiceb_wphester_customize_register($wp_customize){ | |
| 392 | + | |
| 393 | + $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; | |
| 394 | + $sections_customizer_data = array('slider','services','testimonial','team','news'); | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + if (!empty($sections_customizer_data)) | |
| 399 | + { | |
| 400 | + foreach($sections_customizer_data as $section_customizer_data) | |
| 401 | + { | |
| 402 | + require_once('inc/wphester/customizer/'.$section_customizer_data.'-section.php'); | |
| 403 | + } | |
| 404 | + } | |
| 405 | + $wp_customize->remove_control('header_textcolor'); | |
| 406 | + | |
| 407 | + } | |
| 408 | + add_action( 'customize_register', 'spiceb_wphester_customize_register' ); | |
| 409 | + endif; | |
| 410 | + | |
| 411 | + $sections_data = array('slider','services','testimonial','team','news'); | |
| 412 | + | |
| 413 | + if (!empty($sections_data)){ | |
| 414 | + | |
| 415 | + foreach($sections_data as $section_data){ | |
| 416 | + require_once('inc/wphester/sections/wphester-'.$section_data.'-section.php'); | |
| 417 | + } | |
| 418 | + } | |
| 419 | + | |
| 420 | + require_once('inc/wphester/customizer.php'); | |
| 421 | + | |
| 422 | + endif; | |
| 423 | + } | |
| 29 | 424 | } |
| 30 | 425 | add_action( 'init', 'spiceb_activate' ); |
| 31 | 426 | |
| 32 | 427 | |
| 33 | 428 | $theme = wp_get_theme(); |
| 34 | -if ( 'SpicePress' == $theme->name ){ | |
| 35 | - | |
| 36 | - | |
| 429 | +if ( 'SpicePress' == $theme->name || 'SpicePress Dark' == $theme->name || 'Rockers' == $theme->name || 'Content' == $theme->name || 'Certify' == $theme->name || 'Stacy' == $theme->name || 'SpicePress Child Theme' == $theme->name || 'Chilly' == $theme->name || 'SpiceBlue' == $theme->name || 'SpicePress Child' == $theme->name){ | |
| 430 | + | |
| 431 | + | |
| 37 | 432 | register_activation_hook( __FILE__, 'spiceb_install_function'); |
| 38 | 433 | function spiceb_install_function() |
| 39 | 434 | { |
| 40 | - $item_details_page = get_option('item_details_page'); | |
| 435 | +$item_details_page = get_option('item_details_page'); | |
| 41 | 436 | if(!$item_details_page){ |
| 42 | - //post status and options | |
| 43 | - $post = array( | |
| 44 | - 'comment_status' => 'closed', | |
| 45 | - 'ping_status' => 'closed' , | |
| 46 | - 'post_author' => 1, | |
| 47 | - 'post_date' => date('Y-m-d H:i:s'), | |
| 48 | - 'post_name' => 'Home', | |
| 49 | - 'post_status' => 'publish' , | |
| 50 | - 'post_title' => 'Home', | |
| 51 | - 'post_type' => 'page', | |
| 52 | - ); | |
| 53 | - //insert page and save the id | |
| 54 | - $newvalue = wp_insert_post( $post, false ); | |
| 55 | - if ( $newvalue && ! is_wp_error( $newvalue ) ){ | |
| 56 | - update_post_meta( $newvalue, '_wp_page_template', 'template-business.php' ); | |
| 57 | - | |
| 58 | - // Use a static front page | |
| 59 | - $page = get_page_by_title('Home'); | |
| 60 | - update_option( 'show_on_front', 'page' ); | |
| 61 | - update_option( 'page_on_front', $page->ID ); | |
| 62 | - | |
| 437 | + require_once('inc/spicepress/default-pages/upload-media.php'); | |
| 438 | + require_once('inc/spicepress/default-pages/about-page.php'); | |
| 439 | + require_once('inc/spicepress/default-pages/home-page.php'); | |
| 440 | + require_once('inc/spicepress/default-pages/blog-page.php'); | |
| 441 | + require_once('inc/spicepress/default-pages/contact-page.php'); | |
| 442 | + require_once('inc/spicepress/default-pages/portfolio-page.php'); | |
| 443 | + require_once('inc/spicepress/default-widgets/default-widget.php'); | |
| 444 | + update_option( 'item_details_page', 'Done' ); | |
| 445 | + } | |
| 446 | +} | |
| 447 | + | |
| 448 | +} | |
| 449 | + | |
| 450 | + | |
| 451 | +//Honeypress | |
| 452 | +if ( 'HoneyPress' == $theme->name || 'HoneyPress Child' == $theme->name || 'Radix Multipurpose' == $theme->name || 'HoneyWaves' == $theme->name || 'Bizhunt' == $theme->name || 'Tromas' == $theme->name || 'HoneyBee' == $theme->name || 'Honeypress Dark' == $theme->name ){ | |
| 453 | +register_activation_hook( __FILE__, 'spiceb_install_function'); | |
| 454 | +function spiceb_install_function() | |
| 455 | +{ | |
| 456 | +$item_details_page = get_option('item_details_page'); | |
| 457 | + if(!$item_details_page){ | |
| 458 | + require_once('inc/honeypress/default-pages/upload-media.php'); | |
| 459 | + require_once('inc/honeypress/default-pages/home-page.php'); | |
| 460 | + require_once('inc/honeypress/default-pages/blog-page.php'); | |
| 461 | + require_once('inc/honeypress/default-widgets/default-widget.php'); | |
| 462 | + update_option( 'item_details_page', 'Done' ); | |
| 463 | + } | |
| 464 | +} | |
| 465 | +} | |
| 466 | + | |
| 467 | +//CloudPress | |
| 468 | +if ( 'CloudPress' == $theme->name || 'CloudPress Child' == $theme->name || 'CloudPress Dark' == $theme->name || 'CloudPress Agency' == $theme->name || 'CloudPress Business' == $theme->name){ | |
| 469 | +register_activation_hook( __FILE__, 'spiceb_cloudpress_install_function'); | |
| 470 | +function spiceb_cloudpress_install_function() | |
| 471 | +{ | |
| 472 | +$item_details_page = get_option('item_details_page'); | |
| 473 | + if(!$item_details_page){ | |
| 474 | + require_once('inc/cloudpress/default-pages/upload-media.php'); | |
| 475 | + require_once('inc/cloudpress/default-pages/home-page.php'); | |
| 476 | + require_once('inc/cloudpress/default-pages/blog-page.php'); | |
| 477 | + require_once('inc/cloudpress/default-widgets/default-widget.php'); | |
| 478 | + update_option( 'item_details_page', 'Done' ); | |
| 479 | + } | |
| 480 | +} | |
| 481 | +} | |
| 482 | + | |
| 483 | +//Innofit | |
| 484 | +if ( 'Innofit' == $theme->name || 'Innofit Child' == $theme->name){ | |
| 485 | + | |
| 486 | +register_activation_hook( __FILE__, 'spiceb_install_function'); | |
| 487 | +function spiceb_install_function() | |
| 488 | +{ | |
| 489 | +$item_details_page = get_option('item_details_page'); | |
| 490 | + if(!$item_details_page){ | |
| 491 | + require_once('inc/innofit/default-pages/upload-media.php'); | |
| 492 | + require_once('inc/innofit/default-pages/home-page.php'); | |
| 493 | + require_once('inc/innofit/default-widgets/default-widget.php'); | |
| 494 | + require_once('inc/innofit/default-pages/home-custom-menu.php'); | |
| 495 | + update_option( 'item_details_page', 'Done' ); | |
| 496 | + } | |
| 497 | +} | |
| 498 | + | |
| 499 | +} | |
| 500 | + | |
| 501 | +//Metabox Seeting For Chilly Theme | |
| 502 | +if ( 'Chilly' == $theme->name ) | |
| 503 | +{ | |
| 504 | +require_once('inc/chilly/post-meta.php'); | |
| 505 | +} | |
| 506 | + | |
| 507 | +//BusiCare | |
| 508 | +if ( 'BusiCare' == $theme->name || 'BusiCare Child' == $theme->name || 'BusiCare Dark' == $theme->name){ | |
| 509 | + register_activation_hook( __FILE__, 'spiceb_busicare_install_function'); | |
| 510 | + function spiceb_busicare_install_function(){ | |
| 511 | + $item_details_page = get_option('item_details_page'); | |
| 512 | + if(!$item_details_page){ | |
| 513 | + require_once('inc/busicare/default-pages/upload-media.php'); | |
| 514 | + require_once('inc/busicare/default-pages/home-page.php'); | |
| 515 | + require_once('inc/busicare/default-pages/blog-page.php'); | |
| 516 | + require_once('inc/busicare/default-widgets/default-widget.php'); | |
| 517 | + update_option( 'item_details_page', 'Done' ); | |
| 518 | + } | |
| 519 | + } | |
| 520 | +} | |
| 521 | + | |
| 522 | +// Spice Software | |
| 523 | +if ( 'Spice Software' == $theme->name || 'Spice Software Dark' == $theme->name || 'Spice Software Child' == $theme->name){ | |
| 524 | + register_activation_hook( __FILE__, 'spiceb_spice_software_install_function'); | |
| 525 | + function spiceb_spice_software_install_function(){ | |
| 526 | + $item_details_page = get_option('item_details_page'); | |
| 527 | + if(!$item_details_page){ | |
| 528 | + require_once('inc/spice-software/default-pages/upload-media.php'); | |
| 529 | + require_once('inc/spice-software/default-pages/home-page.php'); | |
| 530 | + require_once('inc/spice-software/default-pages/blog-page.php'); | |
| 531 | + require_once('inc/spice-software/default-widgets/default-widget.php'); | |
| 532 | + update_option( 'item_details_page', 'Done' ); | |
| 533 | + } | |
| 534 | + } | |
| 535 | +} | |
| 536 | + | |
| 537 | +// Spiko | |
| 538 | +if ( 'Spiko' == $theme->name || 'Spiko Child' == $theme->name || 'Spiko Dark' == $theme->name){ | |
| 539 | + register_activation_hook( __FILE__, 'spiceb_spiko_install_function'); | |
| 540 | + function spiceb_spiko_install_function(){ | |
| 541 | + $item_details_page = get_option('item_details_page'); | |
| 542 | + if(!$item_details_page){ | |
| 543 | + require_once('inc/spiko/default-pages/upload-media.php'); | |
| 544 | + require_once('inc/spiko/default-pages/home-page.php'); | |
| 545 | + require_once('inc/spiko/default-pages/blog-page.php'); | |
| 546 | + update_option( 'item_details_page', 'Done' ); | |
| 547 | + } | |
| 548 | + } | |
| 549 | +} | |
| 550 | + | |
| 551 | +// WPKites | |
| 552 | +if ( 'WPKites' == $theme->name || 'WPKites Child' == $theme->name || 'WPKites Dark' == $theme->name){ | |
| 553 | + register_activation_hook( __FILE__, 'spiceb_wpkites_install_function'); | |
| 554 | + function spiceb_wpkites_install_function(){ | |
| 555 | + $item_details_page = get_option('item_details_page'); | |
| 556 | + if(!$item_details_page){ | |
| 557 | + require_once('inc/wpkites/default-pages/upload-media.php'); | |
| 558 | + require_once('inc/wpkites/default-pages/home-page.php'); | |
| 559 | + require_once('inc/wpkites/default-pages/blog-page.php'); | |
| 560 | + update_option( 'item_details_page', 'Done' ); | |
| 561 | + } | |
| 562 | + } | |
| 563 | +} | |
| 564 | + | |
| 565 | +// WPHester | |
| 566 | +if ( 'WPHester' == $theme->name || 'WPHester Child' == $theme->name || 'WPHester Dark' == $theme->name){ | |
| 567 | + register_activation_hook( __FILE__, 'spiceb_kites_install_function'); | |
| 568 | + function spiceb_kites_install_function(){ | |
| 569 | + $item_details_page = get_option('item_details_page'); | |
| 570 | + if(!$item_details_page){ | |
| 571 | + require_once('inc/wphester/default-pages/upload-media.php'); | |
| 572 | + require_once('inc/wphester/default-pages/home-page.php'); | |
| 573 | + require_once('inc/wphester/default-pages/blog-page.php'); | |
| 574 | + update_option( 'item_details_page', 'Done' ); | |
| 575 | + } | |
| 576 | + } | |
| 577 | +} | |
| 578 | +//Sanatize for spicepress | |
| 579 | +//radio box sanitization function | |
| 580 | +function spiceb_sanitize_radio( $input, $setting ){ | |
| 581 | + //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only | |
| 582 | + $input = sanitize_key($input); | |
| 583 | + //get the list of possible radio box options | |
| 584 | + $choices = $setting->manager->get_control( $setting->id )->choices; | |
| 585 | + //return input if valid or return default option | |
| 586 | + return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); | |
| 587 | +} | |
| 588 | +//Select sanitization callback | |
| 589 | + function spiceb_select_text_sanitization( $input, $setting ){ | |
| 590 | + | |
| 591 | + //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only | |
| 592 | + $input = sanitize_key($input); | |
| 593 | + | |
| 594 | + //get the list of possible select options | |
| 595 | + $choices = $setting->manager->get_control( $setting->id )->choices; | |
| 596 | + | |
| 597 | + //return input if valid or return default option | |
| 598 | + return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); | |
| 599 | + | |
| 63 | 600 | } |
| 64 | - //save the id in the database | |
| 65 | - update_option( 'item_details_page', $newvalue ); | |
| 66 | - } | |
| 601 | +//Sanatize checkbox | |
| 602 | +function spiceb_sanitize_checkbox( $checked ) { | |
| 603 | + // Boolean check. | |
| 604 | + return ( ( isset( $checked ) && true == $checked ) ? true : false ); | |
| 67 | 605 | } |
| 606 | +//Sanatize text | |
| 607 | +function spiceb_spicepress_home_page_sanitize_text( $input ) { | |
| 608 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 609 | +} | |
| 68 | 610 | |
| 611 | +//Sanatize for honeypress theme | |
| 612 | +function spiceb_honeypress_home_page_sanitize_text( $input ) { | |
| 613 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 69 | 614 | } |
| 70 | -?> | |
| 615 | +//Sanatize for CloudPress theme | |
| 616 | +function spiceb_cloudpress_home_page_sanitize_text( $input ) { | |
| 617 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 618 | +} | |
| 619 | +//Sanatize for Busicare theme | |
| 620 | +function spiceb_busicare_home_page_sanitize_text($input){ | |
| 621 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 622 | +} | |
| 623 | +function spiceb_busicare_sanitize_checkbox($checked) { | |
| 624 | + // Boolean check. | |
| 625 | + return ( ( isset($checked) && true == $checked ) ? true : false ); | |
| 626 | +} | |
| 627 | +//Sanatize for Spice Software theme | |
| 628 | +function spiceb_spice_software_home_page_sanitize_text($input){ | |
| 629 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 630 | +} | |
| 631 | +function spiceb_spice_software_sanitize_checkbox($checked) { | |
| 632 | + // Boolean check. | |
| 633 | + return ( ( isset($checked) && true == $checked ) ? true : false ); | |
| 634 | +} | |
| 635 | +//Sanatize for Spiko theme | |
| 636 | +function spiceb_spiko_home_page_sanitize_text($input){ | |
| 637 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 638 | +} | |
| 639 | +function spiceb_spiko_sanitize_checkbox($checked) { | |
| 640 | + // Boolean check. | |
| 641 | + return ( ( isset($checked) && true == $checked ) ? true : false ); | |
| 642 | +} | |
| 643 | +//Sanatize for wpkites theme | |
| 644 | +function spiceb_wpkites_home_page_sanitize_text($input){ | |
| 645 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 646 | +} | |
| 647 | +function spiceb_wpkites_sanitize_checkbox($checked) { | |
| 648 | + // Boolean check. | |
| 649 | + return ( ( isset($checked) && true == $checked ) ? true : false ); | |
| 650 | +} | |
| 651 | +//Sanatize for hester theme | |
| 652 | +function spiceb_wphester_home_page_sanitize_text($input){ | |
| 653 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 654 | +} | |
| 655 | +function spiceb_wphester_sanitize_checkbox($checked) { | |
| 656 | + // Boolean check. | |
| 657 | + return ( ( isset($checked) && true == $checked ) ? true : false ); | |
| 658 | +} | |
| 659 | +include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 660 | +if ( ! is_plugin_active( 'innofit-plus/innofit-plus.php' ) ): | |
| 661 | + function spiceb_innofit_home_page_sanitize_text( $input ) { | |
| 662 | + return wp_kses_post( force_balance_tags( $input ) ); | |
| 663 | + } | |
| 664 | +endif; | |
| 665 | + | |
| 666 | +add_action( 'init', 'spiceb_load_textdomain' ); | |
| 667 | +/** | |
| 668 | + * Load plugin textdomain. | |
| 669 | + */ | |
| 670 | +function spiceb_load_textdomain() { | |
| 671 | + load_plugin_textdomain( 'spicebox', false, plugin_dir_url(__FILE__). 'languages' ); | |
| 672 | +} | |
| 673 | + | |
| 674 | +function spiceb_save_image_to_media_library($image_url, $image_name = 'image') { | |
| 675 | + // Get the upload directory | |
| 676 | + $upload_dir = wp_upload_dir(); | |
| 677 | + | |
| 678 | + // Get the file name and path | |
| 679 | + $filename = basename($image_url); | |
| 680 | + $file_path = trailingslashit($upload_dir['path']) . $filename; | |
| 681 | + | |
| 682 | + // Check if the image exists in the upload directory (if it's already uploaded) | |
| 683 | + if (file_exists($file_path)) { | |
| 684 | + // Check if this file is already in the Media Library | |
| 685 | + $attachment_id = attachment_url_to_postid($upload_dir['url'] . '/' . $filename); | |
| 686 | + if ($attachment_id) { | |
| 687 | + return $attachment_id; // Return existing attachment ID if found | |
| 688 | + } | |
| 689 | + } | |
| 690 | + | |
| 691 | + // Fetch the image data if it's not found | |
| 692 | + $response = wp_remote_get($image_url); | |
| 693 | + if (is_wp_error($response)) { | |
| 694 | + return new WP_Error('download_error', 'Failed to fetch the image.'); | |
| 695 | + } | |
| 696 | + | |
| 697 | + $image_data = wp_remote_retrieve_body($response); | |
| 698 | + if (empty($image_data)) { | |
| 699 | + return new WP_Error('invalid_image_data', 'The image data is empty.'); | |
| 700 | + } | |
| 701 | + | |
| 702 | + // Save the image data to the upload directory | |
| 703 | + global $wp_filesystem; | |
| 704 | + if (!function_exists('WP_Filesystem')) { | |
| 705 | + require_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 706 | + } | |
| 707 | + WP_Filesystem(); | |
| 708 | + | |
| 709 | + // Save the image using WP_Filesystem | |
| 710 | + if (!$wp_filesystem->put_contents($file_path, $image_data, FS_CHMOD_FILE)) { | |
| 711 | + return new WP_Error('file_write_error', 'Failed to write the image file.'); | |
| 712 | + } | |
| 713 | + | |
| 714 | + // Prepare the file array for insertion | |
| 715 | + $filetype = wp_check_filetype($filename, null); | |
| 716 | + $attachment_data = array( | |
| 717 | + 'post_mime_type' => $filetype['type'], | |
| 718 | + 'post_title' => sanitize_file_name($image_name), | |
| 719 | + 'post_content' => '', | |
| 720 | + 'post_status' => 'inherit', | |
| 721 | + ); | |
| 722 | + | |
| 723 | + // Insert the attachment into the WordPress Media Library | |
| 724 | + $attachment_id = wp_insert_attachment($attachment_data, $file_path); | |
| 725 | + | |
| 726 | + if (is_wp_error($attachment_id)) { | |
| 727 | + return $attachment_id; // Return error if something went wrong | |
| 728 | + } | |
| 729 | + | |
| 730 | + // Generate and save the attachment metadata | |
| 731 | + require_once ABSPATH . 'wp-admin/includes/image.php'; | |
| 732 | + $attachment_metadata = wp_generate_attachment_metadata($attachment_id, $file_path); | |
| 733 | + wp_update_attachment_metadata($attachment_id, $attachment_metadata); | |
| 734 | + | |
| 735 | + return $attachment_id; // Return the attachment ID | |
| 736 | +} | |