Headline
CVE-2020-36755: czr-admin-ccat.php in customizr/4.3.1/core – WordPress Themes
The Customizr theme for WordPress is vulnerable to Cross-Site Request Forgery in versions up to, and including, 4.3.0. This is due to missing or incorrect nonce validation on the czr_fn_post_fields_save() function. This makes it possible for unauthenticated attackers to post fields via a forged request granted they can trick a site administrator into performing an action such as clicking on a link.
1<?php2/**3* Init admin actions : loads the meta boxes,4*5*/6if ( ! class_exists( ‘CZR_admin_init’ ) ) :7 class CZR_admin_init {8 static $instance;9 function __construct () {1011 self::$instance =& $this;12 //enqueue additional styling for admin screens13 add_action( ‘admin_init’ , array( $this, ‘czr_fn_admin_style’ ) );1415 //Load the editor-style specific (post formats and RTL), the user style.css, the active skin16 //add user defined fonts in the editor style (@see the query args add_editor_style below)17 //The hook used to be after_setup_theme, but, don’t know from whic WP version, is_rtl() always returns false at that stage.18 add_action( ‘init’ , array( $this, ‘czr_fn_add_editor_style’) );1920 add_filter( ‘tiny_mce_before_init’ , array( $this, ‘czr_fn_user_defined_tinymce_css’) );21 //refresh the post / CPT / page thumbnail on save. Since v3.3.2.22 add_action ( ‘save_post’ , array( $this, ‘czr_fn_refresh_thumbnail’) , 10, 2);2324 //refresh the terms array (categories/tags pickers options) on term deletion25 add_action ( ‘delete_term’ , array( $this, ‘czr_fn_refresh_terms_pickers_options_cb’), 10, 3 );2627 //UPDATE NOTICE28 add_action( ‘admin_notices’ , array( $this, ‘czr_fn_may_be_display_update_notice’) );29 //always add the ajax action30 add_action( ‘wp_ajax_dismiss_customizr_update_notice’ , array( $this , ‘czr_fn_dismiss_update_notice_action’ ) );3132 add_action( ‘admin_footer’ , array( $this , ‘czr_fn_write_ajax_dismis_script’ ) );3334 /* beautify admin notice text using some defaults the_content filter callbacks */35 foreach ( array( 'wptexturize’, 'convert_smilies’, ‘wpautop’) as $callback ) {36 add_filter( 'czr_update_notice’, $callback );37 }38 }39404142 /*43 * @return void44 * updates the tc-thumb-fld post meta with the relevant thumb id and type45 * @package Customizr46 * @since Customizr 3.3.247 */48 function czr_fn_refresh_thumbnail( $post_id, $post ) {49 // If this is just a revision, don’t send the email.50 if ( wp_is_post_revision( $post_id ) || ( ! empty($post) && ‘auto-draft’ == $post->post_status ) )51 return;5253 //if czr454 if ( czr_fn_is_ms() ) {5556 if ( function_exists( ‘czr_fn_set_thumb_info’ ) )57 czr_fn_set_thumb_info( $post_id );5859 }60 else {6162 if ( ! class_exists( ‘CZR_post_thumbnails’ ) || ! is_object(CZR_post_thumbnails::$instance) ) {63 CZR___::$instance -> czr_fn_req_once( ‘inc/czr-front-ccat.php’ );64 new CZR_post_thumbnails();65 }6667 CZR_post_thumbnails::$instance -> czr_fn_set_thumb_info( $post_id );6869 }7071 }72737475 /*76 * hook : 'delete_term’77 * @return void78 * updates the term pickers related options79 * @package Customizr80 * @since Customizr 3.4.1081 */82 function czr_fn_refresh_terms_pickers_options_cb( $term, $tt_id, $taxonomy ) {83 switch ( $taxonomy ) {8485 //delete categories based options86 case 'category’:87 $this -> czr_fn_refresh_term_picker_options( $term, $option_name = ‘tc_blog_restrict_by_cat’ );88 break;89 }90 }919293 function czr_fn_refresh_term_picker_options( $term, $option_name, $option_group = null ) {94 // czr_fn_get_opt and czr_fn_set_option in core/utils/ class-fire-utils_option95 //home/blog posts category picker96 $_option = czr_fn_opt( $option_name, $option_group, $use_default = false );97 if ( is_array( $_option ) && ! empty( $_option ) && in_array( $term, $_option ) )98 //update the option99 czr_fn_set_option( $option_name, array_diff( $_option, (array)$term ) );100101 //alternative, cycle throughout the cats and keep just the existent ones102 /*if ( is_array( $blog_cats ) && ! empty( $blog_cats ) ) {103 //update the option104 czr_fn_set_option( 'tc_blog_restrict_by_cat’, array_filter( $blog_cats, ‘czr_fn_category_id_exists’ ) );105 }*/106 }107108109 /*110 * hook : ‘czr_add_custom_fonts_to_editor’111 * @return css string112 *113 * @package Customizr114 * @since Customizr 3.2.10115 */116 function czr_fn_maybe_add_gfonts_to_editor() {117 $_font_pair = esc_attr( czr_fn_opt(‘tc_fonts’) );118 $_all_font_pairs = CZR___::$instance -> font_pairs;119 if ( false === strpos($_font_pair,’_g_’) )120 return;121 //Commas in a URL need to be encoded before the string can be passed to add_editor_style.122 //czr_fn_get_font defined in core/utils/class-fire-utils123 return array(124 str_replace(125 ',’,126 '%2C’,127 sprintf( '//fonts.googleapis.com/css?family=%s’, czr_fn_get_font( ‘single’ , $_font_pair ) )128 )129 );130 }131132133134 /**135 * hook : 'admin_init’136 * enqueue additional styling for admin screens137 * @package Customizr138 * @since Customizr 3.0.4139 */140 function czr_fn_admin_style() {141 wp_enqueue_style(142 'tc-admincss’,143 sprintf(‘%1$sback/css/tc_admin%2$s.css’ ,144 CZR_BASE_URL . CZR_ASSETS_PREFIX,145 ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? ‘’ : '.min’146 ),147 array(),148 ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? CUSTOMIZR_VER . time() : CUSTOMIZR_VER149 );150 }151152153154 /**155 * Extract changelog of latest version from readme.txt file156 * @package Customizr157 * @since Customizr 3.0.5158 */159 function czr_fn_extract_changelog() {160161 if( ! file_exists(CZR_BASE."readme.txt") ) {162 return;163 }164 if( ! is_readable(CZR_BASE."readme.txt") ) {165 echo '<p>The changelog in readme.txt is not readable.</p>’;166 return;167 }168169 $stylelines = explode(“\n", implode('’, file(CZR_BASE."readme.txt”)));170 $read = false;171 $i = 0;172173 foreach ($stylelines as $line) {174 //echo 'i = '.$i.’|read = '.$read.’pos = '.strpos($line, '= ').’|line :’.$line.’<br/>’;175 //we stop reading if we reach the next version change176 if ($i == 1 && strpos($line, '= ') === 0 ) {177 $read = false;178 $i = 0;179 }180 //we write the line if between current and previous version181 if ($read) {182 echo $line.’<br/>’;183 }184 //we skip all lines before the current version changelog185 if ($line != strpos($line, '= '.CUSTOMIZR_VER)) {186 if ($i == 0) {187 $read = false;188 }189 }190 //we begin to read after current version title191 else {192 $read = true;193 $i = 1;194 }195 }196 }197198199 /**200 * Customizr styles the visual editor to resemble the theme style,201 * Loads the editor-style specific (post formats and RTL), the active skin, the user style.css, the user_defined fonts202 * @package Customizr203 * @since Customizr 3.2.11204 *205 */206 function czr_fn_add_editor_style() {207 //array_filter to remove empty array items is not needed as wp function get_editor_stylesheets() (since WP 4.0)208 //will do that for us209210 //we need only the relative path, otherwise get_editor_stylesheets() will treat this as external CSS211 //which means:212 //a) child-themes cannot override it213 //b) no check on the file existence will be made (producing the rtl error, for instance : https://github.com/presscustomizr/customizr/issues/926)214215 //as of v4.0.10 the editor-style.css is the classic editor style for the Customizr classic style216 //4.1.23 block editor style introduced for the Customizr modern style only217218 //as of 4.1.38 block editor style introduced for the Customizr modern style too219 $_style_suffix = CZR_DEBUG_MODE || CZR_DEV_MODE ? ‘.css’ : ‘.min.css’ ;220 $_stylesheets = czr_fn_is_ms() ? array( CZR_ASSETS_PREFIX . ‘back/css/block-editor-style’ . $_style_suffix ) : array( CZR_ASSETS_PREFIX . ‘back/css/editor-style’ . $_style_suffix, CZR_ASSETS_PREFIX . ‘back/css/block-editor-style-cs’ . $_style_suffix );221222 $_stylesheets[] = 'style.css’;223 if ( ! czr_fn_is_ms() ) {224 $_stylesheets[] = ‘inc/assets/css/’ . esc_attr( czr_fn_opt( ‘tc_skin’ ) );225 }226227 if ( apply_filters( ‘czr_add_custom_fonts_to_editor’ , false != $this -> czr_fn_maybe_add_gfonts_to_editor() ) )228 $_stylesheets = array_merge( $_stylesheets , $this -> czr_fn_maybe_add_gfonts_to_editor() );229 add_editor_style( $_stylesheets );230231 }232233234235236 /**237 * Extend TinyMCE config with a setup function.238 * See http://www.tinymce.com/wiki.php/API3:event.tinymce.Editor.onInit239 * http://wordpress.stackexchange.com/questions/120831/how-to-add-custom-css-theme-option-to-tinymce240 * @package Customizr241 * @since Customizr 3.2.11242 *243 */244 function czr_fn_user_defined_tinymce_css( $init ) {245246 if ( ! apply_filters( ‘czr_add_custom_fonts_to_editor’ , true ) )247 return $init;248249 if ( ‘tinymce’ != wp_default_editor() )250 return $init;251252 $_css = '’;253 //maybe add rtl class254 $_mce_body_context = is_rtl() ? ‘mce-content-body.rtl’ : 'mce-content-body’;255256 //if modern257 if ( czr_fn_is_ms() ) {258 //some plugins fire tiny mce editor in the customizer259 //in this case, the CZR_resources_fonts class has to be loaded260 if ( ! class_exists(‘CZR_resources_fonts’) || ! is_object(CZR_resources_fonts::$instance) )261 CZR() -> czr_fn_load( array(‘fire’ => array( array(‘core’ , ‘resources_fonts’) ) ), true );262263 if ( class_exists(‘CZR_resources_fonts’) && is_object(CZR_resources_fonts::$instance) ) {264 //fonts265 $_css .= CZR_resources_fonts::$instance -> czr_fn_write_fonts_inline_css( '’, $_mce_body_context );266 }267268 //skin269 //some plugins fire tiny mce editor in the customizer270 //in this case, the CZR_resources_styles class has to be loaded271 if ( ! class_exists(‘CZR_resources_styles’) || ! is_object(CZR_resources_styles::$instance) )272 CZR() -> czr_fn_load( array(‘fire’ => array( array(‘core’ , ‘resources_styles’) ) ), true );273274 if ( class_exists(‘CZR_resources_styles’) && is_object(CZR_resources_styles::$instance) ) {275276 //dynamic skin277 $_css .= CZR_resources_styles::$instance -> czr_fn_maybe_write_skin_inline_css( ‘’ );278279 }280281 }282 //classic283 else {284285 //some plugins fire tiny mce editor in the customizer286 //in this case, the CZR_resource class has to be loaded287 if ( ! class_exists(‘CZR_resources’) || ! is_object(CZR_resources::$instance) ) {288 CZR___::$instance -> czr_fn_req_once( ‘inc/czr-init-ccat.php’ );289 new CZR_resources();290 }291292293 //fonts294 $_css = CZR_resources::$instance -> czr_fn_write_fonts_inline_css( '’, $_mce_body_context );295296 }297298 if ( $_css )299 $init[‘content_style’] = trim(preg_replace('/\s+/’, ' ', $_css ) );300301 return $init;302303 }304305306307 /**********************************************************************************308 * UPDATE NOTICE309 * User gets notified when the version stores in the db option 'last_update_notice’310 * is < current version of the theme (CUSTOMIZR_VER)311 * User can dismiss the notice and the option get updated by ajax to the current version312 * The notice will be displayed a maximum of 5 times and will be automatically dismissed until the next update.313 * => users won’t be notified again until the next update.314 **********************************************************************************/315 /**316 * hook : admin_notices317 */318 function czr_fn_may_be_display_update_notice() {319 //don’t display update notification for a list of versions320 //typically useful when several versions are released in a short time interval321 //to avoid hammering the wp admin dashboard with a new admin notice each time322 if ( ( defined(‘DISPLAY_UPDATE_NOTIFICATION’) && ! DISPLAY_UPDATE_NOTIFICATION ) || ( defined(‘DISPLAY_PRO_UPDATE_NOTIFICATION’) && ! DISPLAY_PRO_UPDATE_NOTIFICATION ) )323 return;324325 $opt_name = CZR_IS_PRO ? ‘last_update_notice_pro’ : ‘last_update_notice’;326 $last_update_notice_values = czr_fn_opt($opt_name);327 $show_new_notice = false;328 $display_ct = 50;329330 if ( ! $last_update_notice_values || ! is_array($last_update_notice_values) ) {331 //first time user of the theme, the option does not exist332 // 1) initialize it => set it to the current Customizr version, displayed 0 times.333 // 2) update in db334 $last_update_notice_values = array( “version” => CUSTOMIZR_VER, “display_count” => 0 );335 czr_fn_set_option( $opt_name, $last_update_notice_values );336 //already user of the theme ?337 if ( czr_fn_user_started_before_version( CUSTOMIZR_VER, CUSTOMIZR_VER ) )338 $show_new_notice = true;339 }340341 $_db_version = $last_update_notice_values[“version”];342 $_db_displayed_count = $last_update_notice_values[“display_count”];343344 // user who just upgraded the theme will be notified until he clicks on the dismiss link345 // when clicking on the dismiss link OR when the notice has been displayed n times.346 // - version will be set to CUSTOMIZR_VER347 // - display_count reset to 0348 if ( version_compare( CUSTOMIZR_VER, $_db_version , ‘>’ ) ) {349 //CASE 1 : displayed less than n times350 if ( $_db_displayed_count < $display_ct ) {351 $show_new_notice = true;352 //increments the counter353 (int) $_db_displayed_count++;354 $last_update_notice_values[“display_count”] = $_db_displayed_count;355 //updates the option val with the new count356 czr_fn_set_option( $opt_name, $last_update_notice_values );357 }358 //CASE 2 : displayed n times => automatic dismiss359 else {360 //reset option value with new version and counter to 0361 $new_val = array( “version” => CUSTOMIZR_VER, “display_count” => 0 );362 czr_fn_set_option( $opt_name, $new_val );363 }//end else364 }//end if365366 if ( ! $show_new_notice )367 return;368369 // prefixed CZR_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603370 if ( ! czr_fn_is_plugin_active(‘nimble-builder/nimble-builder.php’) && class_exists(‘CZR_Plugin_Activation’) && ! CZR_Plugin_Activation::get_instance()->czr_fn_is_notice_dismissed() )371 return;372373 ob_start();374 ?>375 <div class="updated czr-update-notice" style="position:relative">376 <?php377 echo apply_filters(378 ‘czr_update_notice’,379 sprintf(‘<h3>%1$s %2$s %3$s %4$s :D</h3>’,380 __( “Good, you’ve recently upgraded to", “customizr”),381 CZR_IS_PRO ? ‘Customizr Pro’ : 'Customizr’,382 __( “version", “customizr”),383 CUSTOMIZR_VER384 )385 );386 ?>387 <?php388 echo apply_filters(389 'czr_update_notice’,390 sprintf( '<h4>%1$s <a class="” href="%2$s” title="%3$s" target="_blank">%3$s »</a></h4>%4$s’,391 __( “We’d like to introduce the new features we’ve been working on.", “customizr”),392 CZR_WEBSITE . “category/customizr-releases/",393 __( “Read the latest release notes” , “customizr” ),394 ! CZR_IS_PRO ? sprintf( '<p style="position: absolute;right: 7px;top: 4px;"><a class="button button-primary upgrade-to-pro” href="%1$s” title="%2$s" target="_blank">%2$s »</a></p>’,395 esc_url(‘presscustomizr.com/customizr-pro?ref=a&utm_source=usersite&utm_medium=link&utm_campaign=customizr-update-notice’),396 __( “Upgrade to Customizr Pro", “customizr” )397 ) : '’398 )399 );400 ?>401 <p style="text-align:right;position: absolute;font-size: 1.1em;<?php echo is_rtl()? ‘left’ : 'right’;?>: 7px;bottom: -5px;">402 <?php printf('<a href="#” title="%1$s" class="tc-dismiss-update-notice"> ( %1$s <strong>X</strong> ) </a>’,403 __(‘close’ , ‘customizr’)404 );405 ?>406 </p>407 </div>408 <?php409 $_html = ob_get_contents();410 if ($_html) ob_end_clean();411 echo $_html;412 }413414415 /**416 * hook : wp_ajax_dismiss_customizr_update_notice417 * => sets the last_update_notice to the current Customizr version when user click on dismiss notice link418 */419 function czr_fn_dismiss_update_notice_action() {420 check_ajax_referer( ‘dismiss-update-notice-nonce’, ‘dismissUpdateNoticeNonce’ );421 $opt_name = CZR_IS_PRO ? ‘last_update_notice_pro’ : ‘last_update_notice’;422 //reset option value with new version and counter to 0423 $new_val = array( “version” => CUSTOMIZR_VER, “display_count” => 0 );424 czr_fn_set_option( $opt_name, $new_val );425 wp_die();426 }427428429430 /**431 * hook : admin_footer432 */433 function czr_fn_write_ajax_dismis_script() {434 ?>435 <script type="text/javascript" id="tc-dismiss-update-notice">436 ( function($){437 var _ajax_action = function( $_el ) {438 var AjaxUrl = “<?php echo admin_url( ‘admin-ajax.php’ ); ?>",439 _query = {440 action : 'dismiss_customizr_update_notice’,441 dismissUpdateNoticeNonce : “<?php echo wp_create_nonce( ‘dismiss-update-notice-nonce’ ); ?>"442 },443 $ = jQuery,444 request = $.post( AjaxUrl, _query );445446 request.fail( function ( response ) {447 //console.log('response when failed : ', response);448 });449 request.done( function( response ) {450 //console.log(‘RESPONSE DONE’, $_el, response);451 // Check if the user is logged out.452 if ( ‘0’ === response )453 return;454 // Check for cheaters.455 if ( '-1’ === response )456 return;457458 $_el.closest(‘.updated’).slideToggle(‘fast’);459 });460 };//end of fn461462 //on load463 $( function($) {464 $(‘.tc-dismiss-update-notice’).click( function( e ) {465 e.preventDefault();466 _ajax_action( $(this) );467 } );468 } );469470 } )( jQuery );471472473 </script>474 <?php475 }476477 }//end of class478endif;479480?><?php481/**482* Init admin page actions : Welcome, help page483*484*/485if ( ! class_exists( ‘CZR_admin_page’ ) ) :486 class CZR_admin_page {487 static $instance;488 public $support_url;489490 function __construct () {491 self::$instance =& $this;492 //add welcome page in menu493 add_action( ‘admin_menu’ , array( $this , ‘czr_fn_add_welcome_page’ ));494 //config infos495 add_action( ‘__after_welcome_panel’ , array( $this , ‘czr_fn_config_infos’ ), 10 );496 //changelog497 add_action( ‘__after_welcome_panel’ , array( $this , ‘czr_fn_print_changelog’ ), 20);498 //build the support url499 $this -> support_url = CZR_IS_PRO ? esc_url( sprintf(‘%ssupport’ , CZR_WEBSITE ) ) : esc_url(‘wordpress.org/support/theme/customizr’);500 //fix #wpfooter absolute positioning in the welcome and about pages501 add_action( ‘admin_print_styles’ , array( $this, ‘czr_fn_fix_wp_footer_link_style’) );502 //knowledgebase503 if ( CZR_IS_PRO ) {504 add_action( ‘current_screen’ , array( $this , ‘czr_schedule_welcome_page_actions’) );505 }506 }507508509510 /**511 * Add fallback admin page.512 * @package Customizr513 * @since Customizr 1.1514 */515 function czr_fn_add_welcome_page() {516 $_name = __( ‘About Customizr’ , ‘customizr’ );517 $_name = CZR_IS_PRO ? sprintf( '%s Pro’, $_name ) : $_name;518519 $theme_page = add_theme_page(520 $_name, // Name of page521 $_name, // Label in menu522 ‘edit_theme_options’ , // Capability required523 ‘welcome.php’ , // Menu slug, used to uniquely identify the page524 array( $this , ‘czr_fn_welcome_panel’ ) //function to be called to output the content of this page525 );526 }527528529530 /**531 * Render welcome admin page.532 * @package Customizr533 * @since Customizr 3.0.4534 */535 function czr_fn_welcome_panel() {536537 $is_help = isset($_GET[‘help’]) ? true : false;538 $_faq_url = esc_url(‘http://docs.presscustomizr.com/category/90-faq-and-common-issues’);539 $_support_url = $this -> support_url;540 $_theme_name = CZR_IS_PRO ? ‘Customizr Pro’ : 'Customizr’;541542 do_action(‘__before_welcome_panel’);543544 ?>545 <div id="customizr-admin-panel” class="wrap about-wrap">546 <?php547 $title = sprintf( '<h1 class="need-help-title">%1$s %2$s %3$s :)</h1>’,548 __( “Thank you for using", “customizr” ),549 $_theme_name,550 CUSTOMIZR_VER551 );552 echo convert_smilies( $title );553 ?>554555 <?php if ( $is_help && ! CZR_IS_PRO ) : ?>556557 <div class="">558559 </div><!-- .changelog -->560561 <?php else : ?>562563 <div class="about-text tc-welcome">564 <?php565 printf( '<p>%1$s</p>’,566 sprintf( __( “The best way to start with %s is to read the %s and visit the %s.", “customizr”),567 $_theme_name,568 sprintf( '<a href="%1$s” title="%2$s” target="_blank">%2$s</a>’, esc_url(‘docs.presscustomizr.com’), __(“documentation", “customizr”) ),569 sprintf( '<a href="%1$s” title="%2$s” target="_blank">%2$s</a>’, esc_url(‘demo.presscustomizr.com’), __(“demo website", “customizr”) )570 )571 );572 printf( '<p><a href="#customizr-changelog">%1$s</a></p>’,573 __( “Read the changelog", “customizr”)574 );575 ?>576 </div>577578 <?php endif; ?>579580 <?php if ( czr_fn_is_child() ) : ?>581 <div class="changelog point-releases"></div>582583 <div class="tc-upgrade-notice">584 <p>585 <?php586 printf( __(‘You are using a child theme of Customizr %1$s : always check the %2$s after upgrading to see if a function or a template has been deprecated.’ , ‘customizr’),587 'v’.CUSTOMIZR_VER,588 '<strong><a href="#customizr-changelog">changelog</a></strong>’589 );590 ?>591 </p>592 </div>593 <?php endif; ?>594595 <?php do_action( ‘czr_after_welcome_admin_intro’ ); ?>596597 <div class="changelog point-releases"></div>598599 <?php if ( ! CZR_IS_PRO ) : ?>600 <div class="changelog">601602 <div class="feature-section col two-col">603604 <div class="col">605 <h3 style="font-size:1.3em;"><?php _e( ‘Happy user of Customizr?’,’customizr’ ); ?></h3>606 <p><?php _e( 'If you are happy with the theme, say it on wordpress.org and give Customizr a nice review! <br />(We are addicted to your feedbacks…)‘,’customizr’ ) ?></br>607 <a class="button-primary review-customizr” title="Customizr WordPress Theme” href="<?php echo esc_url(‘wordpress.org/support/view/theme-reviews/customizr’) ?>" target="_blank">Review Customizr »</a></p>608 </div>609610 <div class="last-feature col">611 <h3 style="font-size:1.3em;"><?php _e( ‘Follow us’,’customizr’ ); ?></h3>612 <p class="tc-follow"><a href="<?php echo esc_url( CZR_WEBSITE . ‘blog’ ); ?>" target="_blank"><img style="border:none;width:auto;" src="<?php echo CZR_BASE_URL . CZR_ASSETS_PREFIX.’back/img/pc.png?’ . CUSTOMIZR_VER ?>" alt="Press Customizr" /></a></p>613 <!-- Place this tag where you want the widget to render. -->614615 </div><!-- .feature-section -->616 </div><!-- .feature-section col three-col -->617618 </div><!-- .changelog -->619620 <div id="extend" class="changelog">621 <h3 style="text-align:left;font-size:1.3em;"><?php _e(“Go Customizr Pro” ,’customizr’) ?></h3>622623 <div class="feature-section two-col images-stagger-right">624 <div class="col" style="float:right">625 <a class="" title="Go Pro" href="<?php echo esc_url( CZR_WEBSITE . ‘customizr-pro?ref=a&utm_source=usersite&utm_medium=link&utm_campaign=customizr-admin-page’ ); ?>" target="_blank"><img style="border:none;width:auto;" alt="Customizr Pro" src="<?php echo CZR_BASE_URL . CZR_ASSETS_PREFIX.’back/img/customizr-pro.png?’.CUSTOMIZR_VER ?>" class=""></a>626 </div>627 <div class="col" style="float:left">628 <h4 style="text-align: left;"><?php _e(‘Easily take your web design one step further’ ,’customizr’) ?></h4></br>629630 <p style="text-align: left;"><?php _e(“The Customizr Pro WordPress theme allows anyone to create a beautiful, professional and mobile friendly website in a few minutes. In the Pro version, you’ll get all features included in the free version plus many conversion oriented ones, to help you attract and retain more visitors on your websites.” , ‘customizr’) ?>631 </p>632 <p style="text-align:left;">633 <a class="button-primary review-customizr hu-go-pro-btn" title="<?php _e("Discover Customizr Pro",’customizr’) ?>" href="<?php echo esc_url( CZR_WEBSITE . ‘customizr-pro?ref=a&utm_source=usersite&utm_medium=link&utm_campaign=customizr-admin-page’ ); ?>" target="_blank"><?php _e("Discover Customizr Pro",’customizr’) ?> »</a>634 </p>635 </div>636 </div>637 </div>638 <?php endif; //end if ! is_pro ?>639640 <?php do_action( ‘__after_welcome_panel’ ); ?>641642 <div class="return-to-dashboard">643 <a href="<?php echo esc_url( self_admin_url() ); ?>"><?php644 is_blog_admin() ? _e( ‘Go to Dashboard → Home’,’customizr’ ) : _e( ‘Go to Dashboard’,’customizr’ ); ?></a>645 </div>646647 </div><!-- //#customizr-admin-panel -->648 <?php649 }650651652653654 /**655 * Extract changelog of latest version from readme.txt file656 *657 * @package Customizr658 * @since Customizr 3.0.5659 */660 function czr_fn_print_changelog() {661 if ( isset($_GET[‘help’]) )662 return;663 if( ! file_exists( CZR_BASE . “readme.txt” ) ) {664 return;665 }666 if( ! is_readable( CZR_BASE . “readme.txt” ) ) {667 echo '<p>The changelog in readme.txt is not readable.</p>’;668 return;669 }670671 $html = '’;672 $stylelines = explode(“\n", implode('’, file( CZR_BASE . “readme.txt” ) ) );673 $read = false;674 $is_title = false;675676 foreach ($stylelines as $line) {677 $is_title = 0 === strpos($line, '= ');678679 //we start reading after current version title680 if ( 0 === strpos($line, '= '. CUSTOMIZR_VER) ) {681 $read = true;682 }683684 if ( ! $read )685 continue;686687 if ( $is_title ) {688 $html .= sprintf( '<strong>%1$s</strong><br/>’, esc_attr( $line ) );689 } else {690 $html .= sprintf( '<i>%1$s</i><br/>’, esc_attr( $line ) );691 }692 }693 do_action(‘__before_changelog’)694 ?>695 <div id="customizr-changelog” class="changelog">696 <h3><?php printf( __( ‘Changelog in version %1$s’ , ‘customizr’ ) , CUSTOMIZR_VER ); ?></h3>697 <p><?php echo $html ?></p>698 </div>699 <?php700 }701702703704 /*705 * Inspired by Easy Digital Download plugin by Pippin Williamson706 * @since 3.2.1707 */708 function czr_fn_config_infos() {709 global $wpdb;710 $theme_data = wp_get_theme();711 $theme = $theme_data->Name . ' ' . $theme_data->Version;712 $parent_theme = $theme_data->Template;713 if ( ! empty( $parent_theme ) ) {714 $parent_theme_data = wp_get_theme( $parent_theme );715 $parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;716 }717 ?>718<div class="wrap tc-config-info">719<h3><?php _e( 'System Informations’, ‘customizr’ ); ?></h3>720<h4 style="text-align: left"><?php _e( ‘Please include the following informations when posting support requests’ , ‘customizr’ ) ?></h4>721<textarea readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="tc-sysinfo" title="<?php _e( 'To copy the system infos, click below then press Ctrl + C (PC) or Cmd + C (Mac).’, ‘customizr’ ); ?>" style="width: 800px;min-height: 800px;font-family: Menlo,Monaco,monospace;background: 0 0;white-space: pre;overflow: auto;display:block;">722<?php do_action( ‘__system_config_before’ ); ?>723# SITE_URL: <?php echo esc_url( site_url() ) . “\n"; ?>724# HOME_URL: <?php echo esc_url( home_url() ) . “\n"; ?>725# IS MULTISITE : <?php echo is_multisite() ? ‘Yes’ . “\n” : ‘No’ . “\n” ?>726727# ACTIVE THEME : <?php echo $theme . “\n"; ?>728<?php if ( $parent_theme !== $theme ) : ?>729# PARENT THEME : <?php echo $parent_theme . “\n"; ?>730<?php endif; ?>731# WP VERSION : <?php echo get_bloginfo( ‘version’ ) . “\n"; ?>732# PERMALINK STRUCTURE : <?php echo get_option( ‘permalink_structure’ ) . “\n"; ?>733734# ACTIVE PLUGINS :735<?php736$plugins = get_plugins();737$active_plugins = get_option( 'active_plugins’, array() );738739foreach ( $plugins as $plugin_path => $plugin ) {740 // If the plugin isn’t active, don’t show it.741 if ( ! in_array( $plugin_path, $active_plugins ) )742 continue;743744 echo $plugin[‘Name’] . ‘: ' . $plugin[‘Version’] ."\n";745}746747if ( is_multisite() ) :748?>749# NETWORK ACTIVE PLUGINS:750<?php751$plugins = wp_get_active_network_plugins();752$active_plugins = get_site_option( ‘active_sitewide_plugins’, array() );753754foreach ( $plugins as $plugin_path ) {755 $plugin_base = plugin_basename( $plugin_path );756757 // If the plugin isn’t active, don’t show it.758 if ( ! array_key_exists( $plugin_base, $active_plugins ) )759 continue;760761 $plugin = get_plugin_data( $plugin_path );762763 echo $plugin[‘Name’] . ' :’ . $plugin[‘Version’] ."\n";764}765endif;766//GET MYSQL VERSION767global $wpdb;768$mysql_ver = ( ! empty( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) ? @mysqli_get_server_info( $wpdb->dbh ) : ‘’;769?>770771PHP Version: <?php echo PHP_VERSION . "\n"; ?>772MySQL Version: <?php echo $mysql_ver . "\n"; ?>773Web Server Info: <?php echo $_SERVER[‘SERVER_SOFTWARE’] . "\n"; ?>774775WordPress Memory Limit: <?php echo ( $this -> czr_fn_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>776PHP Memory Limit: <?php echo ini_get( ‘memory_limit’ ) . "\n"; ?>777PHP Upload Max Size: <?php echo ini_get( ‘upload_max_filesize’ ) . "\n"; ?>778PHP Post Max Size: <?php echo ini_get( ‘post_max_size’ ) . "\n"; ?>779PHP Upload Max Filesize: <?php echo ini_get( ‘upload_max_filesize’ ) . "\n"; ?>780PHP Time Limit: <?php echo ini_get( ‘max_execution_time’ ) . "\n"; ?>781PHP Max Input Vars: <?php echo ini_get( ‘max_input_vars’ ) . "\n"; ?>782PHP Arg Separator: <?php echo ini_get( ‘arg_separator.output’ ) . "\n"; ?>783PHP Allow URL File Open: <?php echo ini_get( ‘allow_url_fopen’ ) ? “Yes” : "No\n"; ?>784785WP_DEBUG: <?php echo defined( ‘WP_DEBUG’ ) ? WP_DEBUG ? ‘Enabled’ . “\n” : ‘Disabled’ . “\n” : ‘Not set’ . “\n” ?>786787Show On Front: <?php echo get_option( ‘show_on_front’ ) . “\n” ?>788Page On Front: <?php $id = get_option( ‘page_on_front’ ); echo get_the_title( $id ) . ' (#’ . $id . ')' . “\n” ?>789Page For Posts: <?php $id = get_option( ‘page_for_posts’ ); echo get_the_title( $id ) . ' (#’ . $id . ')' . “\n” ?>790<?php do_action( ‘__system_config_after’ ); ?>791</textarea>792</div>793</div>794 <?php795 }//end of function796797798 /**799 * TC Let To Num800 *801 * Does Size Conversions802 *803 *804 * @since 3.2.2805 */806 function czr_fn_let_to_num( $v ) {807 $l = substr( $v, -1 );808 $ret = substr( $v, 0, -1 );809810 switch ( strtoupper( $l ) ) {811 case 'P’: // fall-through812 case 'T’: // fall-through813 case 'G’: // fall-through814 case 'M’: // fall-through815 case 'K’: // fall-through816 $ret *= 1024;817 break;818 default:819 break;820 }821822 return $ret;823 }824825 /**826 * hook : admin_print_styles827 * fix the absolute positioning of the wp footer admin link in the welcome pages828 * @return void829 */830 function czr_fn_fix_wp_footer_link_style() {831 $screen = get_current_screen();832 if ( ! is_object($screen) )833 return;834 if ( ‘appearance_page_welcome’ != $screen-> id )835 return;836 ?>837 <style type="text/css” id="tc-fix-wp-footer-position">838 .wp-admin #wpfooter {bottom: inherit;}839 </style>840 <?php841 }842843 //hook : current_screen844 function czr_schedule_welcome_page_actions() {845 $screen = get_current_screen();846 if ( ‘appearance_page_welcome’ != $screen-> id )847 return;848849 add_action( 'czr_after_welcome_admin_intro’, array( $this, ‘czr_print_hs_doc_content’) );850 add_action( 'admin_enqueue_scripts’, array( $this, ‘czr_enqueue_hs_assets’ ) );851 }852853 //hook : admin_enqueue_scripts854 function czr_enqueue_hs_assets() {855 $screen = get_current_screen();856 if ( ‘appearance_page_welcome’ != $screen-> id )857 return;858 wp_enqueue_style(859 'czr-admin-hs-css’,860 sprintf(‘%1$sback/css/czr-hs-doc%2$s.css’ , CZR_BASE_URL . CZR_ASSETS_PREFIX, ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? ‘’ : ‘.min’ ),861 array(),862 ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? CUSTOMIZR_VER . time() : CUSTOMIZR_VER863 );864 wp_enqueue_script(865 'czr-hs-js’,866 sprintf(‘%1$sback/js/czr-hs-doc%2$s.js’ , CZR_BASE_URL . CZR_ASSETS_PREFIX, ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? ‘’ : ‘.min’ ),867 array( 'jquery’, ‘underscore’ ),868 ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? CUSTOMIZR_VER . time() : CUSTOMIZR_VER,869 $in_footer = false870 );871872 $script_settings = array(873 ‘debug’ => false, // Print debug logs or not874 ‘searchDelay’ => 750, // Delay time in ms after a user stops typing and before search is performed875 ‘minLength’ => 3, // Minimum number of characters required to trigger search876 ‘limit’ => 25, // Max limit for # of results to show877 ‘text’ => array(878 //@translators : keep the strings inside brackets ( like {count} and {minLength} ) untranslated as it will be replaced by a number when parsed in javascript879 ‘result_found’ => __(‘We found {count} article that may help:’ , ‘customizr’),880 ‘results_found’ => __(‘We found {count} articles that may help:’ , ‘customizr’),881 ‘no_results_found’ => __(‘No results found…’ , ‘customizr’),882 ‘enter_search’ => __(‘Please enter a search term.’ , ‘customizr’),883 ‘not_long_enough’ => __(‘Search must be at least {minLength} characters.’ , ‘customizr’),884 ‘error’ => __(‘There was an error fetching search results.’ , ‘customizr’),885 ),886 ‘template’ => array(887 ‘wrap_class’ => 'docs-search-wrap’,888 ‘before’ => '<ul class="docs-search-results">’,889 ‘item’ => sprintf( '<li class="article"><a href="{url}” title="%1$s” target="_blank">{name}<span class="article–open-original” ></span></a><p class="article-preview">{preview} … <a href="{url}” title="%1$s” target="_blank">%2$s</a></p></li>’,890 __( 'Read the full article’, ‘customizr’ ),891 __( 'read more’, ‘customizr’ )892 ),893 ‘after’ => '</ul>’,894 ‘results_found’ => '<span class="{css_class}">{text}</span>’,895 ),896 ‘collections’ => array(), // The collection IDs to search in897898 // Do not modify899 ‘_subdomain’ => 'presscustomizr’,900 );901902 wp_localize_script( 'czr-hs-js’, 'CZRHSParams’, $script_settings );903 }904905906 //hook : czr_after_welcome_admin_intro907 function czr_print_hs_doc_content() {908 ?>909 <form enctype="multipart/form-data" method="post" class="frm-show-form " id="form_m3j26q22">910 <div class="frm_form_fields “>911 <fieldset>912 <div id="frm_field_335_container” class="frm_form_field form-field frm_top_container helpscout-docs">913 <label for="field_6woxqa" class="frm_primary_label">914 <h2><?php _e( 'Search the knowledge base’, ‘customizr’ ); ?></h2>915 <h4 style="text-align:center;font-style: italic;font-weight: normal;"><?php _e( 'In a few keywords, describe the information you are looking for.’, ‘customizr’ ); ?></h4>916 <span class="frm_required"></span>917 </label>918 <input type="text" id="field_6woxqa" name="item_meta[335]" value="" placeholder="<?php _e( 'Ex. Logo upload’, ‘customizr’ ) ;?>" autocomplete="off">919920 <div class="frm_description"><?php _e('<u>Search tips</u> : If you get too many results, try to narrow down your search by prefixing it with “customizr” for example. If there are no results, try different keywords and / or spelling variations’, ‘customizr’ ); ?> </div>921 </div>922 </fieldset>923 </div>924 </form>925 <?php926 }927928 }//end of class929endif;930931?><?php932/**933* Posts, pages and attachment actions and filters934*935*/936if ( ! class_exists( ‘CZR_meta_boxes’ ) ) :937 class CZR_meta_boxes {938 static $instance;939940 public $mixed_meta_boxes_map;941 public $post_meta_boxes_map;942943 public $_minify_resources;944 public $_resouces_version;945946947 function __construct () {948 self::$instance =& $this;949950 $this->_resouces_version = CZR_DEBUG_MODE || CZR_DEV_MODE ? CUSTOMIZR_VER . time() : CUSTOMIZR_VER;951952 $this->_minify_resources = CZR_DEBUG_MODE || CZR_DEV_MODE ? false : true ;953954955 //mixed ( layout, slider ) displayed in various types of posts956 add_action( ‘add_meta_boxes’ , array( $this , ‘czr_fn_mixed_meta_boxes’ )) ;957958 //post ( post formats ) displayed only in post types959 add_action( ‘add_meta_boxes_post’ , array( $this , ‘czr_fn_post_formats_meta_boxes’ )) ;960961 //attachment962 add_action( ‘add_meta_boxes_attachment’ , array( $this , ‘czr_fn_attachment_meta_box’ ));963964965 add_action( ‘__post_slider_infos’ , array( $this , ‘czr_fn_get_post_slider_infos’ ));966967 add_action( ‘save_post’ , array( $this , ‘czr_fn_post_fields_save’ ) );968969 add_action( ‘__attachment_slider_infos’ , array( $this , ‘czr_fn_get_attachment_slider_infos’ ));970971 add_action( ‘edit_attachment’ , array( $this , ‘czr_fn_slide_save’ ));972 add_action( ‘edit_attachment’ , array( $this , ‘czr_fn_post_fields_save’ ));973974 add_action( ‘__show_slides’ , array( $this , ‘czr_fn_show_slides’ ), 10, 2);975976 add_action( ‘wp_ajax_slider_action’ , array( $this , ‘czr_fn_slider_cb’ ));977978 //enqueue slider scripts when needed (will be in the footer)979 //czr_slider_metabox_added is fired when980 //a) the slider attachment metabox is printed: czr_fn_attachment_meta_box981 //b) the slider post metabox is printed: czr_fn_post_slider_box982 add_action( ‘czr_slider_metabox_added’ , array( $this, ‘czr_fn_slider_admin_scripts’) );983984 //enqueue post format script985 add_action( ‘czr_post_formats_metabox_added’ , array( $this , ‘czr_fn_post_formats_admin_scripts’ ) );986987988 /**989 * checks if WP version strictly < 3.5990 * before 3.5, attachments were not managed as posts. But two filter hooks can are very useful991 * @package Customizr992 * @since Customizr 2.0993 */994 global $wp_version;995 if (version_compare( $wp_version, ‘3.5’ , ‘<’ ) ) {996 add_filter( ‘attachment_fields_to_edit’ , array( $this , ‘czr_fn_attachment_filter’ ), 11, 2 );997 add_filter( ‘attachment_fields_to_save’ , array( $this , ‘czr_fn_attachment_save_filter’ ), 11, 2 );998 }9991000 }//end of __construct100110021003 function czr_fn_get_mixed_meta_boxes_map( $_cache = true ) {1004 $_meta_boxes_map = $this->mixed_meta_boxes_map;10051006 if ( !isset($this->mixed_meta_boxes_map) ) {10071008 $_meta_boxes_map = array (1009 //metabox => disallowed screens1010 ‘layout_section’ => array(),1011 //The slider section (slider in posts/pages) metabox MUST NOT be added in attachments1012 ‘slider_section’ => array( ‘attachment’ )1013 );10141015 if ( $_cache )1016 $this->mixed_meta_boxes_map = $_meta_boxes_map;10171018 }10191020 return apply_filters( 'czr_mixed_meta_boxes_map’, $_meta_boxes_map );1021 }102210231024 function czr_fn_get_post_meta_boxes_map( $_cache = true ) {1025 $_meta_boxes_map = $this->post_meta_boxes_map;10261027 if ( !isset($this->post_meta_boxes_map) ) {10281029 $_meta_boxes_map = array (1030 //Post formats1031 'audio_section’,1032 'video_section’,1033 'quote_section’,1034 'link_section’1035 );10361037 if ( $_cache )1038 $this->post_meta_boxes_map = $_meta_boxes_map;10391040 }10411042 return apply_filters( 'czr_meta_boxes_map’, $_meta_boxes_map );1043 }1044104510461047 /*1048 ----------------------------------------------------------------1049 -------- DEFINE POST/PAGE LAYOUT AND SLIDER META BOXES ---------1050 ----------------------------------------------------------------1051 */1052 function czr_add_metabox( $meta_box_key, $screen ) {10531054 if ( ! method_exists( $this , “czr_fn_{$meta_box_key}_metabox” ) )1055 return;10561057 call_user_func_array( 'add_meta_box’,1058 $this->czr_fn_build_metabox_arguments (1059 “{$meta_box_key}id",1060 call_user_func( array( $this, “czr_fn_{$meta_box_key}_metabox” ), $screen )1061 )1062 );10631064 }10651066 /**1067 * Adds layout and slider metaboxes to pages and posts1068 * hook : add_meta_boxes1069 * @package Customizr1070 * @since Customizr 1.01071 */1072 function czr_fn_mixed_meta_boxes( $id ) {//id, title, callback, post_type, context, priority, callback_args1073 /***1074 Determines which screens we display the box1075 **/1076 //1 - retrieves the custom post types1077 $args = array(1078 //we want our metaboxes added only to those custom post types that can be seen on front1079 //the parameter ‘publicly_queryable’ should ensure this.1080 //Example:1081 // - In WooCommerce product post type our metaboxes are visibile while they’re not in WooCommerce orders/coupons …1082 // that cannot be seen in front.1083 // - They’re visible in Tribe Events Calendar’s event post type1084 // - They’re not visible in ACF(-pro) screens1085 // - They’re not visbile in Ultime Responsive image slider post type1086 ‘publicly_queryable’ => true,1087 ‘_builtin’ => false1088 );10891090 $custom_post_types = apply_filters( 'czr_post_metaboxes_cpt’, get_post_types($args) );10911092 //2 - Merging with the builtin post types, pages and posts1093 $builtin_post_types = array(1094 ‘page’ => 'page’,1095 ‘post’ => 'post’,1096 ‘attachment’ => 'attachment’1097 );10981099 $screens = array_merge( $custom_post_types, $builtin_post_types );11001101 $mixed_meta_boxes = $this->czr_fn_get_mixed_meta_boxes_map();110211031104 //3- Adding the meta-boxes to those screens1105 foreach ( $screens as $key => $screen) {1106 foreach ( $mixed_meta_boxes as $meta_box_key => $disallowed_screens_array ) {1107 if ( in_array( $screen, $disallowed_screens_array ) ) {1108 continue;1109 }1110 $this->czr_add_metabox( $meta_box_key, $screen );1111 $_metabox_added = true;1112 }//end foreach11131114 }//end foreach11151116 }11171118 //hook : add_meta_boxes_post1119 function czr_fn_post_formats_meta_boxes( $post ) {1120 //if not czr4 return1121 if ( ! ( defined( ‘CZR_IS_MODERN_STYLE’ ) && CZR_IS_MODERN_STYLE ) )1122 return;11231124 $post_meta_boxes = $this->czr_fn_get_post_meta_boxes_map();11251126 $_metabox_added = false;11271128 foreach ( $post_meta_boxes as $meta_box_key ) {1129 $this->czr_add_metabox( $meta_box_key, ‘post’ );1130 $_metabox_added = true;1131 }//end foreach11321133 if ( $_metabox_added )1134 do_action( 'czr_post_formats_metabox_added’, $post );11351136 }11371138113911401141 //helper1142 function czr_fn_build_metabox_arguments( $id, $args ) {1143 //order matters!1144 //’cause we use call_user_func_array to pass args with a certain order to add_metabox1145 $defaults = array(1146 ‘id’ => $id,1147 ‘title’ => '’,1148 ‘callback’ => null,1149 ‘screen’ => null,1150 ‘context’ => 'advanced’,1151 ‘priority’ => 'high’,1152 ‘callback_args’ => null,1153 );11541155 $args = wp_parse_args( $args, $defaults );11561157 //Filtering1158 $args[ ‘screen’ ] = apply_filters( “czr_fn_{$id}_metabox_screen", apply_filters( 'czr_fn_metaboxes_screen’, $args[‘screen’], $args[‘id’] ), $args[ ‘screen’ ] );1159 $args[ ‘context’ ] = apply_filters( “czr_fn_{$id}_metabox_context", apply_filters( 'czr_fn_metaboxes_context’, $args[‘context’], $args[‘id’] ), $args[ ‘context’ ] );1160 $args[ ‘priority’ ] = apply_filters( “czr_fn_{$id}_metabox_priority", apply_filters( 'czr_fn_metaboxes_priority’, $args[‘priority’], $args[‘id’] ), $args[ ‘priority’ ] );11611162 return $args;1163 }116411651166116711681169 function czr_fn_layout_section_metabox( $screen ) {11701171 return array(1172 ‘title’ => __( ‘Layout Options’ , ‘customizr’ ),1173 ‘callback’ => array( $this , ‘czr_fn_post_layout_box’ ),1174 ‘screen’ => $screen,1175 ‘context’ => in_array( $screen, array( 'page’, 'post’, ‘attachment’ ) ) ? ‘side’ : 'normal’,//displays meta box below editor for custom post types1176 ‘priority’ => 'high’,1177 );11781179 }118011811182 function czr_fn_slider_section_metabox( $screen ) {11831184 return array(1185 ‘title’ => __( ‘Slider Options’ , ‘customizr’ ),1186 ‘callback’ => array( $this , ‘czr_fn_post_slider_box’ ),1187 ‘screen’ => $screen,1188 ‘context’ => 'normal’,//displays meta box below editor for custom post types1189 ‘priority’ => 'high’1190 );11911192 }11931194 function czr_fn_link_section_metabox( $screen ) {11951196 return array(1197 ‘title’ => __( ‘Format: link’ , ‘customizr’ ),1198 ‘callback’ => array( $this , ‘czr_fn_post_format_link_box’ ),1199 ‘screen’ => 'post’,1200 ‘context’ => 'normal’,//displays meta box below editor for custom post types1201 ‘priority’ => 'high’1202 );12031204 }12051206 function czr_fn_quote_section_metabox( $screen ) {12071208 return array(1209 ‘title’ => __( ‘Format: quote’ , ‘customizr’ ),1210 ‘callback’ => array( $this , ‘czr_fn_post_format_quote_box’ ),1211 ‘screen’ => 'post’,1212 ‘context’ => 'normal’,//displays meta box below editor for custom post types1213 ‘priority’ => 'high’1214 );12151216 }12171218 function czr_fn_video_section_metabox( $screen ) {12191220 return array(1221 ‘title’ => __( ‘Format: video’ , ‘customizr’ ),1222 ‘callback’ => array( $this , ‘czr_fn_post_format_video_box’ ),1223 ‘screen’ => 'post’,1224 ‘context’ => 'normal’,//displays meta box below editor for custom post types1225 ‘priority’ => 'high’1226 );12271228 }12291230 function czr_fn_audio_section_metabox( $screen ) {12311232 return array(1233 ‘title’ => __( ‘Format: audio’ , ‘customizr’ ),1234 ‘callback’ => array( $this , ‘czr_fn_post_format_audio_box’ ),1235 ‘screen’ => 'post’,1236 ‘context’ => 'normal’,//displays meta box below editor for custom post types1237 ‘priority’ => 'high’1238 );12391240 }1241124212431244 //Build metabox html124512461247 function czr_fn_post_format_link_box( $post, $args ) {12481249 // Use nonce for verification1250 wp_nonce_field( plugin_basename( __FILE__ ), ‘format_link_noncename’ );12511252 // The actual field for data entry1253 $link = get_post_meta( $post->ID, $key = ‘czr_link_meta’ , $single = true );12541255 $link_title = esc_attr( isset( $link[‘link_title’] ) ? $link[‘link_title’] : ‘’ );1256 $link_url = esc_url( isset( $link[‘link_url’] ) ? $link[‘link_url’] : ‘’ );125712581259 CZR_meta_boxes::czr_fn_generic_input_view( array(1260 ‘input_name’ => 'czr_link_title’,1261 ‘custom_args’ => 'style="max-width:50%"’,1262 ‘title’ => array(12631264 ‘title_text’ => __( 'Link title’, ‘customizr’),1265 ‘title_tag’ => 'h3’,12661267 ),1268 ‘content_before’ => CZR_meta_boxes::czr_fn_title_view( array(1269 ‘title_text’ => __( 'Enter the title’, ‘customizr’),1270 ‘title_tag’ => 'h4’,1271 ‘echo’ => false,1272 ‘boxed’ => false1273 )1274 ),1275 ‘input_value’ => $link_title12761277 ));12781279 CZR_meta_boxes::czr_fn_generic_input_view( array(12801281 ‘input_name’ => 'czr_link_url’,1282 ‘input_type’ => 'url’,1283 ‘custom_args’ => 'style="max-width:50%"’,1284 ‘title’ => array(1285 ‘title_text’ => __( 'Link URL’, ‘customizr’),1286 ‘title_tag’ => 'h3’,1287 ),12881289 ‘content_before’ => CZR_meta_boxes::czr_fn_title_view( array(1290 ‘title_text’ => __( 'Enter the URL’, ‘customizr’),1291 ‘title_tag’ => 'h4’,1292 ‘echo’ => false,1293 ‘boxed’ => false1294 )1295 ),1296 ‘input_value’ => $link_url12971298 ));12991300 }13011302 function czr_fn_post_format_quote_box( $post, $args ) {13031304 // Use nonce for verification1305 wp_nonce_field( plugin_basename( __FILE__ ), ‘format_quote_noncename’ );13061307 // The actual field for data entry1308 $quote = get_post_meta( $post->ID, $key = ‘czr_quote_meta’ , $single = true );13091310 $quote_text = esc_attr( isset( $quote[‘quote_text’] ) ? $quote[‘quote_text’] : ‘’ );1311 $quote_author = esc_attr( isset( $quote[‘quote_author’] ) ? $quote[‘quote_author’] : ‘’ );13121313 CZR_meta_boxes::czr_fn_textarea_view( array(13141315 ‘input_name’ => 'czr_quote_text’,1316 ‘title’ => array(1317 ‘title_text’ => __( 'Quote text’, ‘customizr’),1318 ‘title_tag’ => 'h3’,1319 ),1320 ‘custom_args’ => 'style="max-width:50%"’,1321 ‘content_before’ => CZR_meta_boxes::czr_fn_title_view( array(1322 ‘title_text’ => __( 'Enter the text’, ‘customizr’),1323 ‘title_tag’ => 'h4’,1324 ‘echo’ => false,1325 ‘boxed’ => false1326 )1327 ),13281329 ‘input_value’ => $quote_text13301331 ));13321333 CZR_meta_boxes::czr_fn_generic_input_view( array(13341335 ‘input_name’ => 'czr_quote_author’,1336 ‘title’ => array(1337 ‘title_text’ => __( 'Quote author’, ‘customizr’),1338 ‘title_tag’ => 'h3’,1339 ),13401341 ‘custom_args’ => 'style="max-width:50%"’,1342 ‘content_before’ => CZR_meta_boxes::czr_fn_title_view( array(1343 ‘title_text’ => __( 'Enter the author’, ‘customizr’),1344 ‘title_tag’ => 'h4’,1345 ‘echo’ => false,1346 ‘boxed’ => false1347 )1348 ),13491350 ‘input_value’ => $quote_author1351 ));1352 }135313541355 function czr_fn_post_format_audio_box( $post, $args ) {13561357 // Use nonce for verification1358 wp_nonce_field( plugin_basename( __FILE__ ), ‘format_audio_noncename’ );13591360 // The actual field for data entry1361 $audio = get_post_meta( $post->ID, $key = ‘czr_audio_meta’ , $single = true );13621363 $audio_url = esc_url( isset( $audio[‘audio_url’] ) ? $audio[‘audio_url’] : ‘’ );13641365 CZR_meta_boxes::czr_fn_generic_input_view( array(13661367 ‘input_name’ => 'czr_audio_url’,1368 ‘custom_args’ => 'style="max-width:50%"’,1369 ‘title’ => array(1370 ‘title_text’ => __( 'Audio url’, ‘customizr’),1371 ‘title_tag’ => 'h3’,1372 ),1373 ‘content_before’ => CZR_meta_boxes::czr_fn_title_view( array(1374 ‘title_text’ => __( 'Enter the audio url’, ‘customizr’),1375 ‘title_tag’ => 'h4’,1376 ‘echo’ => false,1377 ‘boxed’ => false1378 )1379 ),1380 ‘input_value’ => $audio_url,1381 ‘input_type’ => 'url’13821383 ));13841385 }1386138713881389 function czr_fn_post_format_video_box( $post, $args ) {13901391 // Use nonce for verification1392 wp_nonce_field( plugin_basename( __FILE__ ), ‘format_video_noncename’ );13931394 // The actual field for data entry1395 $video = get_post_meta( $post->ID, $key = ‘czr_video_meta’ , $single = true );13961397 $video_url = esc_url( isset( $video[‘video_url’] ) ? $video[‘video_url’] : ‘’ );13981399 CZR_meta_boxes::czr_fn_generic_input_view( array(14001401 ‘input_name’ => 'czr_video_url’,1402 ‘custom_args’ => 'style="max-width:50%"’,1403 ‘title’ => array(1404 ‘title_text’ => __( 'Video url’, ‘customizr’),1405 ‘title_tag’ => 'h3’,1406 ),1407 ‘content_before’ => CZR_meta_boxes::czr_fn_title_view( array(1408 ‘title_text’ => __( 'Enter the video url’, ‘customizr’),1409 ‘title_tag’ => 'h4’,1410 ‘echo’ => false,1411 ‘boxed’ => false1412 )1413 ),1414 ‘input_value’ => $video_url,1415 ‘input_type’ => 'url’14161417 ));14181419 }14201421142214231424 /**1425 * Prints the box content1426 * @package Customizr1427 * @since Customizr 1.01428 */1429 function czr_fn_post_layout_box( $post ) {1430 // Use nonce for verification1431 wp_nonce_field( plugin_basename( __FILE__ ), ‘post_layout_noncename’ );14321433 // The actual fields for data entry1434 // Use get_post_meta to retrieve an existing value from the database and use the value for the form1435 //Layout name setup1436 $layout_id = 'layout_field’;14371438 $layout_value = esc_attr(get_post_meta( $post->ID, $key = ‘layout_key’ , $single = true ));14391440 //Generates layouts select list array1441 $layouts = array();1442 $global_layout = apply_filters( ‘tc_global_layout’ , CZR_init::$instance->global_layout );1443 foreach ( $global_layout as $key => $value ) {1444 $layouts[$key] = call_user_func( ‘__’ , $value[‘metabox’] , ‘customizr’ );1445 }14461447 //by default we apply the global default layout1448 $tc_sidebar_default_context_layout = esc_attr( czr_fn_opt( ‘page’ == $post->post_type ? ‘tc_sidebar_page_layout’ : ‘tc_sidebar_post_layout’ ) );144914501451 ?>1452 <div class="meta-box-item-content">1453 <?php if( $layout_value == null) : ?>1454 <p><?php printf(__( ‘Default %1$s layout is set to : %2$s’ , ‘customizr’ ), ‘page’ == $post->post_type ? __( ‘pages’ , ‘customizr’ ):__( ‘posts’ , ‘customizr’ ), ‘<strong>’.$layouts[$tc_sidebar_default_context_layout].’</strong>’ ) ?></p>1455 <?php endif; ?>14561457 <i><?php printf(__( ‘You can define a specific layout for %1$s by using the pre-defined left and right sidebars. The default layouts can be defined in the WordPress customizer screen %2$s.<br />’ , ‘customizr’ ),1458 $post->post_type == ‘page’ ? __( ‘this page’ , ‘customizr’ ):__( ‘this post’ , ‘customizr’ ),1459 '<a href="’.admin_url( ‘customize.php’ ).’” target="_blank">’.__( ‘here’ , ‘customizr’ ).’</a>’1460 ); ?>1461 </i>1462 <h4><?php printf(__( ‘Select a specific layout for %1$s’ , ‘customizr’ ),1463 $post->post_type == ‘page’ ? __( ‘this page’ , ‘customizr’ ):__( ‘this post’ , ‘customizr’ )); ?></h4>1464 <select name="<?php echo $layout_id; ?>” id="<?php echo $layout_id; ?>">1465 <?php //no layout selected ?>1466 <option value="” <?php selected( $layout_value, $current = null, $echo = true ) ?>> <?php printf(__( ‘Default layout %1s’ , ‘customizr’ ),1467 '( ‘.$layouts[$tc_sidebar_default_context_layout].’ )'1468 );1469 ?></option>1470 <?php foreach( $layouts as $key => $l) : ?>1471 <option value="<?php echo $key; ?>” <?php selected( $layout_value, $current = $key, $echo = true ) ?>><?php echo $l; ?></option>1472 <?php endforeach; ?>1473 </select>14741475 </div>14761477 <?php14781479 do_action( 'czr_post_metabox_added’, $post );1480 do_action( 'czr_post_layout_metabox_added’, $post );1481 }1482148314841485148614871488 /*1489 ----------------------------------------------------------------1490 ------------------ POST/PAGE SLIDER BOX ------------------------1491 ----------------------------------------------------------------1492 */149314941495 /**1496 * Prints the slider box content1497 * @package Customizr1498 * @since Customizr 2.01499 */1500 function czr_fn_post_slider_box( $post ) {1501 // Use nonce for verification1502 wp_nonce_field( plugin_basename( __FILE__ ), ‘post_slider_noncename’ );15031504 // The actual fields for data entry1505 //title check field setup1506 $post_slider_check_id = 'post_slider_check_field’;1507 $post_slider_check_value = esc_attr(get_post_meta( $post->ID, $key = ‘post_slider_check_key’ , $single = true ));15081509 ?>1510 <input name="tc_post_id" id="tc_post_id" type="hidden" value="<?php echo $post-> ID ?>"/>1511 <div class="meta-box-item-title">1512 <h4><label for="<?php echo $post_slider_check_id; ?>"><?php _e( ‘Add a slider to this post/page’ , ‘customizr’ ); ?></label></h4>1513 </div>1514 <div class="meta-box-item-content">1515 <?php1516 $post_slider_checked = false;1517 if ( $post_slider_check_value == 1) {1518 $post_slider_checked = true;1519 }1520 CZR_meta_boxes::czr_fn_checkbox_view( array(1521 ‘input_name’ => $post_slider_check_id,1522 ‘input_state’ => $post_slider_checked,1523 ));1524 ?>1525 </div>1526 <div id="slider-fields-box">1527 <?php do_action( ‘__post_slider_infos’ , $post->ID ); ?>1528 </div>1529 <?php15301531 do_action( 'czr_post_metabox_added’, $post );1532 do_action( 'czr_slider_metabox_added’, $post );15331534 }//end of function153515361537153815391540 /**1541 * Display post slider dynamic content1542 * This function is also called by the ajax call back1543 * @package Customizr1544 * @since Customizr 2.01545 */1546 function czr_fn_get_post_slider_infos( $postid ) {1547 //check value is ajax saved ?1548 $post_slider_check_value = esc_attr(get_post_meta( $postid, $key = ‘post_slider_check_key’ , $single = true ));15491550 //retrieve all sliders in option array1551 $options = get_option( ‘tc_theme_options’ );1552 if ( isset($options[‘tc_sliders’]) ) {1553 $sliders = $options[‘tc_sliders’];1554 }else1555 $sliders = array();15561557 //post slider fields setup1558 $post_slider_id = 'post_slider_field’;15591560 //get current post slider1561 $current_post_slider = esc_attr(get_post_meta( $postid, $key = ‘post_slider_key’ , $single = true ));1562 if ( isset( $sliders[$current_post_slider])) {1563 $current_post_slides = $sliders[$current_post_slider];1564 }15651566 //Delay field setup1567 $delay_id = 'slider_delay_field’;1568 $delay_value = esc_attr(get_post_meta( $postid, $key = ‘slider_delay_key’ , $single = true ));15691570 //Layout field setup1571 $layout_id = 'slider_layout_field’;1572 $layout_value = esc_attr(get_post_meta( $postid, $key = ‘slider_layout_key’ , $single = true ));15731574 //overlay field setup1575 $overlay_id = 'slider_overlay_field’;1576 $overlay_value = esc_attr(get_post_meta( $postid, $key = ‘slider_overlay_key’ , $single = true ));15771578 //dots field setup1579 $dots_id = 'slider_dots_field’;1580 $dots_value = esc_attr(get_post_meta( $postid, $key = ‘slider_dots_key’ , $single = true ));15811582 //sliders field1583 $slider_id = 'slider_field’;15841585 if( $post_slider_check_value == true ):1586 $selectable_sliders = apply_filters( 'czr_post_selectable_sliders’, $sliders );1587 if ( isset( $selectable_sliders ) && ! empty( $selectable_sliders ) ):15881589 ?>1590 <div class="meta-box-item-title">1591 <h4><?php _e(“Choose a slider", ‘customizr’ ); ?></h4>1592 </div>1593 <?php1594 //build selectable slider->ID => label1595 //Default in head1596 $selectable_sliders = array_merge( array(1597 -1 => __( '— Select a slider — ' , ‘customizr’ )1598 ), $selectable_sliders );15991600 //in case of sliders of images we set the label as the slider_id1601 if ( isset($sliders) && !empty( $sliders) )1602 foreach ( $sliders as $key => $value) {1603 if ( is_array( $value ) )1604 $selectable_sliders[ $key ] = $key;1605 }1606 ?>1607 <div class="meta-box-item-content">1608 <span class="spinner” style="float: left;visibility:visible;display: none;"></span>1609 <select name="<?php echo $post_slider_id; ?>" id="<?php echo $post_slider_id; ?>">1610 <?php //sliders select choices1611 foreach ( $selectable_sliders as $id => $label ) {1612 printf( '<option value="%1$s" %2$s> %3$s</option>’,1613 esc_attr( $id ),1614 selected( $current_post_slider, esc_attr( $id ), $echo = false ),1615 $label1616 );1617 }1618 ?>1619 </select>1620 <i><?php _e( ‘To create a new slider : open the media library, edit your images and add them to your new slider.’ , ‘customizr’ ) ?></i>1621 </div>16221623 <div class="meta-box-item-title">1624 <h4><?php _e(“Delay between each slides in milliseconds (default : 5000 ms)“, ‘customizr’ ); ?></h4>1625 </div>1626 <div class="meta-box-item-content">1627 <input name="<?php echo esc_attr( $delay_id) ; ?>” id="<?php echo esc_attr( $delay_id); ?>” value="<?php if (empty( $delay_value)) { echo '5000’;} else {echo esc_attr( $delay_value);} ?>"/>1628 </div>16291630 <div class="meta-box-item-title">1631 <h4><?php _e(“Slider Layout : set the slider in full width", ‘customizr’ ); ?></h4>1632 </div>1633 <div class="meta-box-item-content">1634 <?php1635 if ( $layout_value ==null || $layout_value ==1 )1636 {1637 $layout_check_value = true;1638 }1639 else {1640 $layout_check_value = false;1641 }1642 CZR_meta_boxes::czr_fn_checkbox_view( array(1643 ‘input_name’ => $layout_id,1644 ‘input_state’ => $layout_check_value,1645 ));1646 ?>1647 </div>1648 <?php if ( CZR_IS_MODERN_STYLE ) : ?>1649 <div class="meta-box-item-title">1650 <h4><?php _e(“Apply a dark overlay on your slider’s images", ‘customizr’ ); ?></h4>1651 </div>1652 <div class="meta-box-item-content">1653 <?php1654 if ( $overlay_value == null || ‘on’ == $overlay_value || 1 === $overlay_value || true === $overlay_value )1655 {1656 $overlay_check_value = true;1657 }1658 else {1659 $overlay_check_value = false;1660 }1661 CZR_meta_boxes::czr_fn_checkbox_view( array(1662 ‘input_name’ => $overlay_id,1663 ‘input_state’ => $overlay_check_value,1664 ));1665 ?>1666 </div>16671668 <div class="meta-box-item-title">1669 <h4><?php _e(“Display navigation dots at the bottom of your slider.", ‘customizr’ ); ?></h4>1670 </div>1671 <div class="meta-box-item-content">1672 <?php1673 if ( $dots_value == null || ‘on’ == $dots_value || 1 === $dots_value || true === $dots_value ) {1674 $dots_check_value = true;1675 }1676 else {1677 $dots_check_value = false;1678 }1679 CZR_meta_boxes::czr_fn_checkbox_view( array(1680 ‘input_name’ => $dots_id,1681 ‘input_state’ => $dots_check_value,1682 ));1683 ?>1684 </div>1685 <?php endif; ?>1686 <?php if (isset( $current_post_slides)) : ?>1687 <div style="z-index: 1000;position: relative;">1688 <p style="display: inline-block;float: right;"><a href="#TB_inline?width=350&height=100&inlineId=post_slider-warning-message” class="thickbox"><?php _e( ‘Delete this slider’ , ‘customizr’ ) ?></a></p>1689 </div>1690 <div id="post_slider-warning-message” style="display:none;">1691 <div style="text-align:center">1692 <p>1693 <?php _e( ‘The slider will be deleted permanently (images, call to actions and link will be kept).’ , ‘customizr’ ) ?>1694 </p>1695 <br/>1696 <a class="button-secondary” id="delete-slider" href="#" title="<?php _e( ‘Delete slider’ , ‘customizr’ ); ?>" onClick="javascript:window.parent.tb_remove()“><?php _e( ‘Delete slider’ , ‘customizr’ ); ?></a>1697 </div>1698 </div>1699 <?php do_action( ‘__show_slides’ , $current_post_slides, $current_attachement_id = null); ?>1700 <?php else: //there are no slides1701 do_action( '__no_slides’, $postid, $current_post_slider );1702 ?>1703 <?php endif; //slides? ?>1704 <?php else://if no slider created yet and no slider of posts addon?>17051706 <div class="meta-box-item-content">1707 <p class="description"> <?php _e(“You haven’t create any slider yet. Go to the media library, edit your images and add them to your sliders.", “customizr” ) ?><br/>1708 </p>1709 <br />1710 </div>1711 <?php endif; //sliders? ?>1712 <?php endif; //check slider? ?>1713 <?php1714 }1715171617171718171917201721 /*1722 ----------------------------------------------------------------1723 ------- SAVE POST/PAGE FIELDS (LAYOUT AND SLIDER FIELDS) -------1724 ----------------------------------------------------------------1725 */1726 /**1727 * When the post/page is saved, saves our custom data for slider and layout options1728 * @package Customizr1729 * @since Customizr 1.01730 */1731 function czr_fn_post_fields_save( $post_id, $post_object = null ) {1732 // verify if this is an auto save routine.1733 // If it is our form has not been submitted, so we dont want to do anything1734 if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )1735 return;17361737 // Check permissions1738 if ( isset( $_POST[‘post_type’]) && ‘page’ == $_POST[‘post_type’] )1739 {1740 if ( !current_user_can( ‘edit_page’ , $post_id ) )1741 return;1742 }1743 else1744 {1745 if ( !current_user_can( ‘edit_post’ , $post_id ) )1746 return;1747 }17481749 //LINK1750 $this->czr_fn_link_save( $post_id, $post_object );175117521753 //QUOTE1754 $this->czr_fn_quote_save( $post_id, $post_object );17551756 //AUDIO1757 $this->czr_fn_audio_save( $post_id, $post_object );17581759 //VIDEO1760 $this->czr_fn_video_save( $post_id, $post_object );17611762 ################# LAYOUT BOX #################1763 // verify this came from our screen and with proper authorization,1764 if ( isset( $_POST[‘post_layout_noncename’]) && !wp_verify_nonce( $_POST[‘post_layout_noncename’], plugin_basename( __FILE__ ) ) )1765 return;17661767 // OK, we’re authenticated: we need to find and save the data1768 //set up the fields array1769 $tc_post_layout_fields = array(1770 ‘layout_field’ => 'layout_key’1771 );17721773 //if saving in a custom table, get post_ID1774 if ( isset( $_POST[‘post_ID’])) {1775 $post_ID = $_POST[‘post_ID’];1776 //sanitize user input by looping on the fields1777 foreach ( $tc_post_layout_fields as $tcid => $tckey) {1778 if ( isset( $_POST[$tcid])) {1779 $mydata = sanitize_text_field( $_POST[$tcid] );17801781 // Do something with $mydata1782 // either using1783 add_post_meta( $post_ID, $tckey, $mydata, true) or1784 update_post_meta( $post_ID, $tckey , $mydata);1785 // or a custom table (see Further Reading section below)1786 }1787 }1788 }17891790 ################# SLIDER BOX #################1791 // verify this came from our screen and with proper authorization,1792 if ( isset( $_POST[‘post_slider_noncename’]) && !wp_verify_nonce( $_POST[‘post_slider_noncename’], plugin_basename( __FILE__ ) ) )1793 return;179417951796 // OK, we’re authenticated: we need to find and save the data1797 //set up the fields array1798 $tc_post_slider_fields = array(1799 ‘post_slider_check_field’ => 'post_slider_check_key’,1800 ‘slider_delay_field’ => 'slider_delay_key’,1801 ‘slider_layout_field’ => 'slider_layout_key’,1802 ‘slider_overlay_field’ => 'slider_overlay_key’,1803 ‘slider_dots_field’ => 'slider_dots_key’,1804 ‘post_slider_field’ => 'post_slider_key’,1805 );18061807 //if saving in a custom table, get post_ID1808 if ( isset( $_POST[‘post_ID’])) {1809 do_action( '__before_save_post_slider_fields’, $_POST, $tc_post_slider_fields );1810 $post_ID = $_POST[‘post_ID’];1811 //sanitize user input by looping on the fields1812 foreach ( $tc_post_slider_fields as $tcid => $tckey) {1813 if ( isset( $_POST[$tcid])) {1814 if ( in_array( $tcid, array( 'slider_overlay_field’, ‘slider_dots_field’ ) ) ) {1815 $mydata = 0 == $_POST[$tcid] ? ‘off’ : 'on’;1816 $mydata = sanitize_text_field( $mydata );1817 } else {1818 $mydata = sanitize_text_field( $_POST[$tcid] );1819 }18201821 // Do something with $mydata1822 // either using1823 add_post_meta( $post_ID, $tckey, $mydata, true) or1824 update_post_meta( $post_ID, $tckey , $mydata);1825 // or a custom table (see Further Reading section below)1826 }1827 }1828 do_action( '__after_save_post_slider_fields’, $_POST, $tc_post_slider_fields );1829 }183018311832 }1833183418351836 /**1837 * When the post/page is saved, saves our custom data for link1838 */1839 function czr_fn_link_save( $post_id ) {18401841 // verify if this is an auto save routine.1842 // If it is our form has not been submitted, so we dont want to do anything1843 if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )1844 return $post_id;18451846 // Check permissions1847 if ( !isset($post_id) || !isset( $_POST[‘post_type’] ) || !isset( $_POST[‘format_link_noncename’] ) )1848 return $post_id;18491850 if ( !wp_verify_nonce( $_POST[‘format_link_noncename’], plugin_basename( __FILE__ ) ) )1851 return $post_id;18521853 if ( !current_user_can( ‘edit_post’ , $post_id ) )1854 return $post_id;18551856 //check field existence1857 if ( !( isset( $_POST[ ‘czr_link_title’ ] ) && isset( $_POST[ ‘czr_link_url’ ] ) ) )1858 return $post_id;18591860 if ( ‘post’ != $_POST[ ‘post_type’ ] )1861 return $post_id;18621863 if ( ‘link’ != get_post_format( $post_id ) )1864 return $post_id;186518661867 //build custom post meta1868 $czr_link_format_meta = array(1869 ‘link_title’ => sanitize_text_field( $_POST[ ‘czr_link_title’ ] ),1870 ‘link_url’ => esc_url( $_POST[ ‘czr_link_url’ ] )1871 );18721873 //update1874 add_post_meta( $post_id, 'czr_link_meta’, $czr_link_format_meta, true ) or1875 update_post_meta( $post_id, 'czr_link_meta’, $czr_link_format_meta );18761877 }1878187918801881 /**1882 * When the post/page is saved, saves our custom data for quote1883 */1884 function czr_fn_quote_save( $post_id ) {18851886 // verify if this is an auto save routine.1887 // If it is our form has not been submitted, so we dont want to do anything1888 if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )1889 return $post_id;18901891 // Check permissions1892 if ( !isset($post_id) || !isset( $_POST[‘post_type’] ) || !isset( $_POST[‘format_quote_noncename’] ) )1893 return $post_id;18941895 if ( !wp_verify_nonce( $_POST[‘format_link_noncename’], plugin_basename( __FILE__ ) ) )1896 return $post_id;18971898 if ( !current_user_can( ‘edit_post’ , $post_id ) )1899 return $post_id;19001901 //check field existence1902 if ( !( isset( $_POST[ ‘czr_quote_text’ ] ) && isset( $_POST[ ‘czr_quote_author’ ] ) ) )1903 return $post_id;19041905 if ( ‘post’ != $_POST[ ‘post_type’ ] )1906 return $post_id;19071908 if ( ‘quote’ != get_post_format( $post_id ) )1909 return $post_id;19101911 //build custom post meta1912 $czr_quote_format_meta = array(1913 ‘quote_text’ => sanitize_text_field( $_POST[ ‘czr_quote_text’ ] ),1914 ‘quote_author’ => sanitize_text_field( $_POST[ ‘czr_quote_author’ ] )1915 );19161917 //update1918 add_post_meta( $post_id, 'czr_quote_meta’, $czr_quote_format_meta, true ) or1919 update_post_meta( $post_id, 'czr_quote_meta’, $czr_quote_format_meta );19201921 }19221923 /**1924 * When the post/page is saved, saves our custom data for audio1925 */1926 function czr_fn_audio_save( $post_id ) {19271928 // verify if this is an auto save routine.1929 // If it is our form has not been submitted, so we dont want to do anything1930 if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )1931 return $post_id;19321933 // Check permissions1934 if ( !isset($post_id) || !isset( $_POST[‘post_type’] ) || !isset( $_POST[‘format_audio_noncename’] ) )1935 return $post_id;19361937 if ( !wp_verify_nonce( $_POST[‘format_audio_noncename’], plugin_basename( __FILE__ ) ) )1938 return $post_id;19391940 if ( !current_user_can( ‘edit_post’ , $post_id ) )1941 return $post_id;19421943 //check field existence1944 if ( !( isset( $_POST[ ‘czr_audio_url’ ] ) ) )1945 return $post_id;19461947 if ( ‘post’ != $_POST[ ‘post_type’ ] )1948 return $post_id;19491950 if ( ‘audio’ != get_post_format( $post_id ) )1951 return $post_id;195219531954 //build custom post meta1955 $czr_audio_format_meta = array(1956 ‘audio_url’ => esc_url( $_POST[ ‘czr_audio_url’ ] )1957 );19581959 //update1960 add_post_meta( $post_id, 'czr_audio_meta’, $czr_audio_format_meta, true ) or1961 update_post_meta( $post_id, 'czr_audio_meta’, $czr_audio_format_meta );19621963 }1964196519661967 /**1968 * When the post/page is saved, saves our custom data for video1969 */1970 function czr_fn_video_save( $post_id ) {19711972 // verify if this is an auto save routine.1973 // If it is our form has not been submitted, so we dont want to do anything1974 if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )1975 return $post_id;19761977 // Check permissions1978 if ( !isset($post_id) || !isset( $_POST[‘post_type’] ) || !isset( $_POST[‘format_video_noncename’] ) )1979 return $post_id;19801981 if ( !wp_verify_nonce( $_POST[‘format_video_noncename’], plugin_basename( __FILE__ ) ) )1982 return $post_id;19831984 if ( !current_user_can( ‘edit_post’ , $post_id ) )1985 return $post_id;19861987 //check field existence1988 if ( !( isset( $_POST[ ‘czr_video_url’ ] ) ) )1989 return $post_id;19901991 if ( ‘post’ != $_POST[ ‘post_type’ ] )1992 return $post_id;19931994 if ( ‘video’ != get_post_format( $post_id ) )1995 return $post_id;199619971998 //build custom post meta1999 $czr_video_format_meta = array(2000 ‘video_url’ => esc_url( $_POST[ ‘czr_video_url’ ] )2001 );20022003 //update2004 add_post_meta( $post_id, 'czr_video_meta’, $czr_video_format_meta, true ) or2005 update_post_meta( $post_id, 'czr_video_meta’, $czr_video_format_meta );20062007 }200820092010 /*2011 ----------------------------------------------------------------2012 ------------------ ATTACHMENT SLIDER META BOX ------------------2013 ----------------------------------------------------------------2014 */2015 /**2016 * Add a slider metabox to attachments2017 * @package Customizr2018 * @since Customizr 2.02019 */2020 function czr_fn_attachment_meta_box( $id ) {//id, title, callback, post_type, context, priority, callback_args2021 if ( ! wp_attachment_is_image( $id ) )2022 return;20232024 add_meta_box(2025 ‘slider_sectionid’ ,2026 __( ‘Slider Options’ , ‘customizr’ ),2027 array( $this , ‘czr_fn_attachment_slider_box’ )2028 );20292030 }20312032203320342035203620372038 /**2039 * Prints the slider box content2040 * @package Customizr2041 * @since Customizr 2.02042 */2043 function czr_fn_attachment_slider_box( $post ) {2044 // Use nonce for verification2045 //wp_nonce_field( plugin_basename( __FILE__ ), ‘slider_noncename’ );2046 // The actual fields for data entry2047 //title check field setup2048 $slider_check_id = 'slider_check_field’;2049 $slider_check_value = esc_attr(get_post_meta( $post->ID, $key = ‘slider_check_key’ , $single = true ));20502051 ?>2052 <div class="meta-box-item-title">2053 <h4><label for="<?php echo $slider_check_id; ?>"><?php _e( 'Add to a slider (create one if needed)' , ‘customizr’ ) ?></label></h4>2054 </div>2055 <div class="meta-box-item-content">2056 <input name="tc_post_id” id="tc_post_id” type="hidden" value="<?php echo $post->ID ?>"/>2057 <?php2058 $slider_checked = false;2059 if ( $slider_check_value == 1) {2060 $slider_checked = true;2061 }2062 CZR_meta_boxes::czr_fn_checkbox_view( array(2063 ‘input_name’ => $slider_check_id,2064 ‘input_state’ => $slider_checked,2065 ));2066 ?>2067 </div>2068 <div id="slider-fields-box">2069 <?php do_action( ‘__attachment_slider_infos’ , $post->ID); ?>2070 </div>2071 <?php20722073 do_action( 'czr_attachment_metabox_added’, $post );2074 do_action( 'czr_slider_metabox_added’, $post );2075 }20762077207820792080208120822083 /**2084 * Display attachment slider dynamic content2085 * This function is also called by the ajax call back function2086 * @package Customizr2087 * @since Customizr 2.02088 */2089 function czr_fn_get_attachment_slider_infos( $postid ) {2090 //check value is ajax saved ?2091 $slider_check_value = esc_attr(get_post_meta( $postid, $key = ‘slider_check_key’ , $single = true ));20922093 //post slider fields setup2094 $post_slider_id = 'post_slider_field’;20952096 //sliders field2097 $slider_id = 'slider_field’;20982099 //retrieve all sliders in option array2100 $options = get_option( ‘tc_theme_options’ );2101 $sliders = array();2102 if ( isset( $options[‘tc_sliders’])) {2103 $sliders = $options[‘tc_sliders’];2104 }21052106 //get_attachment details for default slide values2107 $attachment = get_post( $postid);2108 $default_title = $attachment->post_title;2109 $default_description = $attachment->post_excerpt;21102111 //title field setup2112 $title_id = 'slide_title_field’;2113 $title_value = esc_attr(get_post_meta( $postid, $key = ‘slide_title_key’ , $single = true ));2114 //we define a filter for the slide_text_length2115 $default_title_length = apply_filters( 'tc_slide_title_length’, apply_filters( 'czr_slide_title_length’, 80 ) );21162117 //check if we already have a custom key created for this field, if not apply default value2118 if(!in_array( ‘slide_title_key’ ,get_post_custom_keys( $postid))) {2119 $title_value = $default_title;2120 }2121 $title_value = esc_html( czr_fn_text_truncate( $title_value, $default_title_length, ‘…’ ) );212221232124 //text_field setup : sanitize and limit length2125 $text_id = 'slide_text_field’;2126 $text_value = esc_html(get_post_meta( $postid, $key = ‘slide_text_key’ , $single = true ));2127 //we define a filter for the slide_title_length2128 $default_text_length = apply_filters( 'tc_slide_text_length’, apply_filters( 'czr_slide_text_length’, 250 ) );21292130 //check if we already have a custom key created for this field, if not apply default value2131 if(!in_array( ‘slide_text_key’ ,get_post_custom_keys( $postid)))2132 $text_value = $default_description;2133 $text_value = czr_fn_text_truncate( $text_value, $default_text_length, ‘…’ );213421352136 //Color field setup2137 $color_id = 'slide_color_field’;2138 $color_value = esc_attr(get_post_meta( $postid, $key = ‘slide_color_key’ , $single = true ));21392140 //button field setup2141 $button_id = 'slide_button_field’;2142 $button_value = esc_attr(get_post_meta( $postid, $key = ‘slide_button_key’ , $single = true ));21432144 //we define a filter for the slide text_button length2145 $default_button_length = apply_filters( 'tc_slide_button_length’, apply_filters( 'czr_slide_button_length’, 80 ) );2146 $button_value = czr_fn_text_truncate( $button_value, $default_button_length, ‘…’ );2147214821492150 //link field setup2151 $link_id = 'slide_link_field’;2152 $link_value = esc_attr(get_post_meta( $postid, $key = ‘slide_link_key’ , $single = true ));21532154 //retrieve post, pages and custom post types (if any) and generate the ordered select list for the button link2155 $post_types = get_post_types(array( ‘public’ => true));2156 $excludes = array( ‘attachment’ );215721582159 foreach ( $post_types as $t) {2160 if (!in_array( $t, $excludes)) {2161 //get the posts a tab of types2162 $tc_all_posts[$t] = get_posts( array(2163 ‘numberposts’ => 100,2164 ‘orderby’ => ‘date’ ,2165 ‘order’ => ‘DESC’ ,2166 ‘post_type’ => $t,2167 ‘post_status’ => ‘publish’ )2168 );2169 }2170 };21712172 //custom link field setup2173 $custom_link_id = 'slide_custom_link_field’;2174 $custom_link_value = esc_url( get_post_meta( $postid, $key = 'slide_custom_link_key’, $single = true ) );21752176 //link target setup2177 $link_target_id = 'slide_link_target_field’;2178 $link_target_value = esc_attr( get_post_meta( $postid, $key = 'slide_link_target_key’, $single = true ) ) ;21792180 //link whole slide setup2181 $link_whole_slide_id = 'slide_link_whole_slide_field’;2182 $link_whole_slide_value = esc_attr( get_post_meta( $postid, $key = 'slide_link_whole_slide_key’, $single = true ) ) ;21832184 //display fields if slider button is checked2185 if ( $slider_check_value == true ) {2186 ?>2187 <div class="meta-box-item-title">2188 <h4><?php _e( 'Title text (80 char. max length)' , ‘customizr’ ); ?></h4>2189 </div>2190 <div class="meta-box-item-content">2191 <input class="widefat" name="<?php echo esc_attr( $title_id); ?>" id="<?php echo esc_attr( $title_id); ?>" value="<?php echo esc_attr( $title_value); ?>" style="width:50%">2192 </div>21932194 <div class="meta-box-item-title">2195 <h4><?php _e( 'Description text (below the title, 250 char. max length)' , ‘customizr’ ); ?></h4>2196 </div>2197 <div class="meta-box-item-content">2198 <textarea name="<?php echo esc_attr( $text_id); ?>" id="<?php echo esc_attr( $text_id); ?>" style="width:50%"><?php echo esc_html( $text_value); ?></textarea>2199 </div>22002201 <div class="meta-box-item-title">2202 <h4><?php _e(“Title and text color", ‘customizr’ ); ?></h4>2203 </div>2204 <div class="meta-box-item-content">2205 <input id="<?php echo esc_attr( $color_id); ?>” name="<?php echo esc_attr( $color_id); ?>" value="<?php echo esc_attr( $color_value); ?>"/>2206 <div id="colorpicker"></div>2207 </div>22082209 <div class="meta-box-item-title">2210 <h4><?php _e( 'Button text (80 char. max length)' , ‘customizr’ ); ?></h4>2211 </div>2212 <div class="meta-box-item-content">2213 <input class="widefat" name="<?php echo esc_attr( $button_id); ?>" id="<?php echo esc_attr( $button_id); ?>" value="<?php echo esc_attr( $button_value); ?>" style="width:50%">2214 </div>22152216 <div class="meta-box-item-title">2217 <h4><?php _e(“Choose a linked page or post (among the last 100).", ‘customizr’ ); ?></h4>2218 </div>2219 <div class="meta-box-item-content">2220 <select name="<?php echo esc_attr( $link_id); ?>” id="<?php echo esc_attr( $link_id); ?>">2221 <?php //no link option ?>2222 <option value="" <?php selected( $link_value, $current = null, $echo = true ) ?>> <?php _e( ‘No link’ , ‘customizr’ ); ?></option>2223 <?php foreach( $tc_all_posts as $type) : ?>2224 <?php foreach ( $type as $key => $item) : ?>2225 <option value="<?php echo esc_attr( $item->ID); ?>" <?php selected( $link_value, $current = $item->ID, $echo = true ) ?>>{<?php echo esc_attr( $item->post_type) ;?>} <?php echo esc_attr( $item->post_title); ?></option>2226 <?php endforeach; ?>2227 <?php endforeach; ?>2228 </select><br />2229 </div>2230 <div class="meta-box-item-title">2231 <h4><?php _e(“or a custom link (leave this empty if you already selected a page or post above)“, ‘customizr’ ); ?></h4>2232 </div>2233 <div class="meta-box-item-content">2234 <input class="widefat” name="<?php echo $custom_link_id; ?>” id="<?php echo $custom_link_id; ?>" value="<?php echo $custom_link_value; ?>" style="width:50%">2235 </div>2236 <div class="meta-box-item-title">2237 <h4><?php _e(“Open link in a new page/tab", ‘customizr’ ); ?></h4>2238 </div>2239 <div class="meta-box-item-content">2240 <?php2241 CZR_meta_boxes::czr_fn_checkbox_view( array(2242 ‘input_name’ => $link_target_id,2243 ‘input_state’ => $link_target_value,2244 ));2245 ?>2246 </div>2247 <div class="meta-box-item-title">2248 <h4><?php _e(“Link the whole slide", ‘customizr’ ); ?></h4>2249 </div>2250 <div class="meta-box-item-content">2251 <?php2252 CZR_meta_boxes::czr_fn_checkbox_view( array(2253 ‘input_name’ => $link_whole_slide_id,2254 ‘input_state’ => $link_whole_slide_value,2255 ));2256 ?>2257 </div>2258 <div class="meta-box-item-title">2259 <h4><?php _e(“Choose a slider", ‘customizr’ ); ?></h4>2260 </div>2261 <?php if (!empty( $sliders)) : ?>2262 <div class="meta-box-item-content">2263 <?php //get current post slider2264 $current_post_slider = null;2265 foreach( $sliders as $slider_name => $slider_posts) {2266 if (in_array( $postid, $slider_posts)) {2267 $current_post_slider = $slider_name;2268 $current_post_slides = $slider_posts;2269 }2270 }2271 ?>2272 <select name="<?php echo esc_attr( $post_slider_id); ?>” id="<?php echo esc_attr( $post_slider_id); ?>">2273 <?php //no link option ?>2274 <option value="” <?php selected( $current_post_slider, $current = null, $echo = true ) ?>> <?php _e( '— Select a slider — ' , ‘customizr’ ); ?></option>2275 <?php foreach( $sliders as $slider_name => $slider_posts) : ?>2276 <option value="<?php echo $slider_name ?>” <?php selected( $slider_name, $current = $current_post_slider, $echo = true ) ?>><?php echo $slider_name?></option>2277 <?php endforeach; ?>2278 </select>2279 <input name="<?php echo $slider_id ?>" id="<?php echo $slider_id ?>" value=""/>2280 <span class="button-primary" id="tc_create_slider"><?php _e( ‘Add a slider’ , ‘customizr’ ) ?></span>2281 <span class="spinner" style="float: left;visibility:visible;display: none;"></span>2282 <?php if (isset( $current_post_slides)) : ?>2283 <p style="text-align:right"><a href="#TB_inline?width=350&height=100&inlineId=slider-warning-message" class="thickbox"><?php _e( ‘Delete this slider’ , ‘customizr’ ) ?></a></p>2284 <div id="slider-warning-message" style="display:none;">2285 <div style="text-align:center">2286 <p>2287 <?php _e( ‘The slider will be deleted permanently (images, call to actions and link will be kept).’ , ‘customizr’ ) ?>2288 </p>2289 <br/>2290 <a class="button-secondary" id="delete-slider" href="#" title="<?php _e( ‘Delete slider’ , ‘customizr’ ); ?>" onClick="javascript:window.parent.tb_remove()“><?php _e( ‘Delete slider’ , ‘customizr’ ); ?></a>2291 </div>2292 </div>2293 <?php endif; ?>2294 </div>229522962297 <?php2298 if ( isset( $current_post_slides) ) {2299 $current_attachement_id = $postid;2300 do_action( ‘__show_slides’ ,$current_post_slides, $current_attachement_id);2301 }2302 ?>23032304 <?php else : //if no slider created yet ?>23052306 <div class="meta-box-item-content">2307 <p class="description"> <?php _e(“You haven’t create any slider yet. Write a slider name and click on the button to add you first slider.", “customizr” ) ?><br/>2308 <input name="<?php echo $slider_id ?>” id="<?php echo $slider_id ?>” value=""/>2309 <span class="button-primary" id="tc_create_slider"><?php _e( ‘Add a slider’ , ‘customizr’ ) ?></span>2310 <span class="spinner" style="float: left; diplay:none;"></span>2311 </p>2312 <br />2313 </div>2314 <?php endif; ?>2315 <?php2316 }//endif slider checked (used for ajax call back!)2317 }231823192320232123222323 /*2324 ----------------------------------------------------------------2325 -------------------- SAVE ATTACHMENT FIELDS --------------------2326 ----------------------------------------------------------------2327 */23282329 /**2330 * When the attachment is saved, saves our custom slider data2331 * @package Customizr2332 * @since Customizr 2.02333 */2334 function czr_fn_slide_save( $post_id ) {2335 // verify if this is an auto save routine.2336 // If it is our form has not been submitted, so we dont want to do anything233723382339 if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )2340 return;23412342 // verify this came from our screen and with proper authorization,2343 // because save_post can be triggered at other times23442345 if ( isset( $_POST[‘slider_noncename’]) && !wp_verify_nonce( $_POST[‘slider_noncename’], plugin_basename( __FILE__ ) ) )2346 return;23472348 // Check permissions2349 if ( !current_user_can( ‘edit_post’ , $post_id ) )2350 return;23512352 // OK, we’re authenticated: we need to find and save the data23532354 //set up the fields array2355 $tc_slider_fields = array(2356 ‘slide_title_field’ => ‘slide_title_key’ ,2357 ‘slide_text_field’ => ‘slide_text_key’ ,2358 ‘slide_color_field’ => ‘slide_color_key’ ,2359 ‘slide_button_field’ => ‘slide_button_key’ ,2360 ‘slide_link_field’ => ‘slide_link_key’ ,2361 ‘slide_custom_link_field’ => 'slide_custom_link_key’,2362 ‘slide_link_target_field’ => 'slide_link_target_key’,2363 ‘slide_link_whole_slide_field’ => 'slide_link_whole_slide_key’2364 );23652366 //if saving in a custom table, get post_ID2367 if ( $post_id == null)2368 return;23692370 //sanitize user input by looping on the fields2371 foreach ( $tc_slider_fields as $tcid => $tckey) {2372 if ( isset( $_POST[$tcid])) {2373 $mydata = sanitize_text_field( $_POST[$tcid] );23742375 switch ( $tckey) {2376 //different sanitizations2377 case 'slide_text_key’:2378 $default_text_length = apply_filters( 'tc_slide_text_length’, apply_filters( 'czr_slide_text_length’, 250 ) );2379 $mydata = esc_html( czr_fn_text_truncate( $mydata, $default_text_length, ‘…’ ) );2380 break;23812382 case 'slide_title_key’:2383 $default_title_length = apply_filters( 'tc_slide_title_length’, apply_filters( 'czr_slide_title_length’, 80 ) );2384 $mydata = esc_html( czr_fn_text_truncate( $mydata, $default_title_length, ‘…’ ) );2385 break;23862387 case 'slide_button_key’:2388 $default_button_text_length = apply_filters( 'tc_slide_button_length’, apply_filters( 'czr_slide_button_length’, 80 ) );2389 $mydata = esc_html( czr_fn_text_truncate( $mydata, $default_button_text_length, ‘…’ ) );2390 break;23912392 case 'slide_custom_link_key’:2393 $mydata = esc_url( $_POST[$tcid] );2394 break;23952396 case 'slide_link_target_key’;2397 case 'slide_link_whole_slide_key’:2398 $mydata = esc_attr( $mydata );2399 break;24002401 default://for color, post link field (actually not a link but an id)2402 $mydata = esc_attr( $mydata );2403 break;2404 }//end switch2405 //write in DB2406 add_post_meta( $post_id, $tckey, $mydata, true) or2407 update_post_meta( $post_id, $tckey , $mydata);2408 }//end if isset $tckey2409 }//end foreach2410 }2411241224132414241524162417 /*2418 ----------------------------------------------------------------2419 ---------- DISPLAY SLIDES TABLE (post and attachment) ----------2420 ----------------------------------------------------------------2421 */24222423 /**2424 * Display slides table dynamic content for the selected slider2425 * @package Customizr2426 * @since Customizr 2.02427 */2428 function czr_fn_show_slides ( $current_post_slides,$current_attachement_id) {2429 //check if we have slides to show2430 ?>2431 <?php if(empty( $current_post_slides)) : ?>2432 <div class="meta-box-item-content">2433 <p class="description"> <?php _e(“This slider has not slides to show. Go to the media library and start adding images to it.", “customizr” ) ?><br/>2434 </p>2435 <br />2436 </div>2437 <?php else : // render?>2438 <div id="tc_slides_table">2439 <div id="update-status"></div>2440 <table class="wp-list-table widefat fixed media” cellspacing="0">2441 <thead>2442 <tr>2443 <th scope="col"><?php _e( ‘Slide Image’ , ‘customizr’ ) ?></th>2444 <th scope="col"><?php _e( ‘Title’ , ‘customizr’ ) ?></th>2445 <th scope="col" style="width: 35%"><?php _e( ‘Slide Text’ , ‘customizr’ ) ?></th>2446 <th scope="col"><?php _e( ‘Button Text’ , ‘customizr’ ) ?></th>2447 <th scope="col"><?php _e( ‘Link’ , ‘customizr’ ) ?></th>2448 <th scope="col"><?php _e( ‘Edit’ , ‘customizr’ ) ?></th>2449 </tr>2450 </thead>2451 <tbody id="sortable">2452 <?php2453 //loop on the slides and render if the selected slider is checked2454 foreach ( $current_post_slides as $index => $slide) {2455 //get the attachment object2456 $tc_slide = get_post( $slide );24572458 //check if $tc_slide object exists otherwise go to the next iteration2459 if (!isset( $tc_slide))2460 continue;24612462 //check if slider is checked for this attachment => otherwise go to the next iteration2463 $slider_check_value = esc_attr(get_post_meta( $tc_slide->ID, $key = ‘slider_check_key’ , $single = true ));2464 if ( $slider_check_value == false)2465 continue;24662467 //set up variables2468 $id = $tc_slide->ID;2469 $slide_src = wp_get_attachment_image_src( $id, ‘thumbnail’ );2470 $slide_url = $slide_src[0];2471 $title = esc_attr(get_post_meta( $id, $key = ‘slide_title_key’ , $single = true ));2472 $text = esc_html(get_post_meta( $id, $key = ‘slide_text_key’ , $single = true ));2473 $text_color = esc_attr(get_post_meta( $id, $key = ‘slide_color_key’ , $single = true ));2474 $button_text = esc_attr(get_post_meta( $id, $key = ‘slide_button_key’ , $single = true ));2475 $link = esc_url(get_post_meta( $id, $key = ‘slide_custom_link_key’ , $single = true ));2476 $button_link = esc_attr(get_post_meta( $id, $key = ‘slide_link_key’ , $single = true ));24772478 //check if $text_color is set and create an html style attribute2479 $color_style =’’;2480 if( $text_color != null) {2481 $color_style = 'style="color:’.$text_color.’"’;2482 }2483 ?>2484 <tr id="<?php echo $index ?>" class="ui-state-default" valign="middle">2485 <td style="vertical-align:middle" class="column-icon">2486 <?php if( $slide_url != null) : ?>2487 <img width="100" height="100" src="<?php echo $slide_url; ?>" class="attachment-80x60" alt="Hydrangeas">2488 <?php else : ?>2489 <div style="height:100px;width:100px;background:#eee;text-align:center;line-height:100px;vertical-align:middle">2490 <?php _e( ‘No Image Selected’ , ‘customizr’ ); ?>2491 </div>2492 <?php endif; ?>2493 </td>2494 <td style="vertical-align:middle" class="">2495 <?php if( $title != null) : ?>2496 <p <?php echo $color_style ?>><strong><?php echo $title ?></strong></p>2497 <?php endif; ?>2498 </td>2499 <td style="vertical-align:middle" class="">2500 <?php if( $text != null) : ?>2501 <p <?php echo $color_style ?> class="lead"><?php echo $text ?></p>2502 <?php endif; ?>2503 </td>2504 <td style="vertical-align:middle" class="">2505 <?php if( $button_text != null) : ?>2506 <p class="btn btn-large btn-primary"><?php echo $button_text; ?></p>2507 <?php endif; ?>2508 </td>2509 <td style="vertical-align:middle" class="">2510 <?php if( $button_link != null || $link != null ) : ?>2511 <p class="btn btn-large btn-primary" href="<?php echo $link ? $link : get_permalink( $button_link); ?>"><?php echo $link ? $link : get_the_title( $button_link); ?></p>2512 <?php endif; ?>2513 </td>2514 <td style="vertical-align:middle" class="">2515 <?php if( $id != $current_attachement_id) : ?>2516 <a class="button-primary" href="<?php echo admin_url( ‘post.php?post=’.$id.’&action=edit’ ) ?>" target="_blank"><?php _e( ‘Edit this slide’ , ‘customizr’ )?></a>2517 <?php else : ?>2518 <span style="color:#999898"><?php _e( ‘Current slide’ , ‘customizr’ )?></span>2519 <?php endif; ?>2520 </td>2521 </tr>2522 <?php2523 }//end foreach2524 echo '</tbody></table><br/>’;2525 ?>2526 <div class="tc-add-slide-notice">2527 <?php2528 printf('<p>%1$s</p><p>%2$s <a href="%3$s" title="%4$s" target="_blank">%4$s »</a>.</p>’,2529 __(‘To add another slide : navigate to your media library (click on Media), open the edit screen of an image ( or add a new image ), and add it to your desired slider by using the dedicated option block at the bottom of the page.’ , ‘customizr’),2530 __(‘For more informations about sliders, check the documentation page :’ , ‘customizr’),2531 esc_url(‘http://docs.presscustomizr.com/search?query=slider’),2532 __(‘Slider documentation’ , ‘customizr’)2533 );2534 ?>2535 </div>2536 </div><!-- //#tc_slides_table -->2537 <?php endif; // empty( $current_post_slides? ?>2538 <?php2539 }254025412542254325442545 /*2546 ----------------------------------------------------------------2547 ---------------- AJAX SAVE (post and attachment) ---------------2548 ----------------------------------------------------------------2549 */2550 /**2551 * Ajax saving of options and meta fields in DB for post and attachement screens2552 * works along with tc_ajax_slider.js2553 * @package Customizr2554 * @since Customizr 2.02555 */2556 function czr_fn_slider_ajax_save( $post_id ) {25572558 //We check the ajax nonce (common for post and attachment)2559 if ( isset( $_POST[‘SliderCheckNonce’]) && !wp_verify_nonce( $_POST[‘SliderCheckNonce’], ‘tc-slider-check-nonce’ ) )2560 return;25612562 // Check permissions2563 if ( !current_user_can( ‘edit_post’ , $post_id ) )2564 return;25652566 // Do we have a post_id?2567 if ( !isset( $_POST[‘tc_post_id’])) {2568 return;2569 }2570 else {2571 $post_ID = $_POST[‘tc_post_id’];2572 }25732574 //OPTION FIELDS2575 //get options and some useful $_POST vars2576 $czr_options = get_option( ‘tc_theme_options’ );25772578 if (isset( $_POST[‘tc_post_type’]))2579 $tc_post_type = esc_attr( $_POST[‘tc_post_type’]);2580 if (isset( $_POST[‘currentpostslider’]))2581 $current_post_slider = esc_attr( $_POST[‘currentpostslider’]);2582 if (isset( $_POST[‘new_slider_name’]))2583 $new_slider_name = esc_attr( $_POST[‘new_slider_name’] );25842585 //Save user input by looping on the fields2586 foreach ( $_POST as $tckey => $tcvalue) {2587 switch ( $tckey) {2588 //delete slider2589 case 'delete_slider’:2590 //first we delete the meta fields related to the deleted slider2591 //which screen are we coming from?2592 if( $tc_post_type == ‘attachment’ ) {2593 query_posts( 'meta_key=post_slider_key&meta_value=’.$current_post_slider);2594 //we loop the posts with the deleted slider meta key2595 if(have_posts()) {2596 while ( have_posts() ) : the_post();2597 //delete the post meta2598 delete_post_meta(get_the_ID(), $key = ‘post_slider_key’ );2599 endwhile;2600 }2601 wp_reset_query();2602 }26032604 //we delete from the post/page screen2605 else {2606 $post_slider_meta = esc_attr(get_post_meta( $post_ID, $key = ‘post_slider_key’ , $single = true ));2607 if(!empty( $post_slider_meta)) {2608 delete_post_meta( $post_ID, $key = ‘post_slider_key’ );2609 }2610 }26112612 //in all cases, delete DB option2613 unset( $czr_options[‘tc_sliders’][$current_post_slider]);2614 //update DB with new slider array2615 update_option( ‘tc_theme_options’ , $czr_options );2616 break;261726182619 //reorder slides2620 case 'newOrder’:2621 //turn new order into array2622 if(!empty( $tcvalue))26232624 $neworder = explode( ‘,’ , esc_attr( $tcvalue ));26252626 //initialize the newslider array2627 $newslider = array();26282629 foreach ( $neworder as $new_key => $new_index) {2630 $newslider[$new_index] = $czr_options[‘tc_sliders’][$current_post_slider][$new_index];2631 }26322633 $czr_options[‘tc_sliders’][$current_post_slider] = $newslider;26342635 //update DB with new slider array2636 update_option( ‘tc_theme_options’ , $czr_options );2637 break;26382639264026412642 //sliders are added in options2643 case 'new_slider_name’:2644 //check if we have something to save2645 $new_slider_name = esc_attr( $tcvalue );2646 $delete_slider = false;2647 if ( isset( $_POST[‘delete_slider’]))2648 $delete_slider = $_POST[‘delete_slider’];26492650 //prevent saving if we delete2651 if (!empty( $new_slider_name) && $delete_slider != true) {2652 $new_slider_name = wp_filter_nohtml_kses( $tcvalue );2653 //remove spaces and special char2654 $new_slider_name = strtolower(preg_replace(“![^a-z0-9]+!i", "-“, $new_slider_name));26552656 $czr_options[‘tc_sliders’][$new_slider_name] = array( $post_ID);2657 //adds the new slider name in DB options2658 update_option( ‘tc_theme_options’ , $czr_options );2659 //associate the current post with the new saved slider26602661 //looks for a previous slider entry and delete it2662 foreach ( $czr_options[‘tc_sliders’] as $slider_name => $slider) {26632664 foreach ( $slider as $key => $tc_post) {2665 //clean empty values if necessary2666 if ( is_null( $czr_options[‘tc_sliders’][$slider_name][$key]))2667 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);26682669 //delete previous slider entries for this post2670 if ( $tc_post == $post_ID )2671 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2672 }2673 }26742675 //update DB with clean option table2676 update_option( ‘tc_theme_options’ , $czr_options );26772678 //push new post value for the new slider and write in DB2679 array_push( $czr_options[‘tc_sliders’][$new_slider_name], $post_ID);2680 update_option( ‘tc_theme_options’ , $czr_options );26812682 }26832684 break;26852686 //post slider value2687 case 'post_slider_name’:2688 //check if we display the attachment screen2689 if (!isset( $_POST[‘slider_check_field’])) {2690 break;2691 }2692 //we are in the attachment screen and we uncheck slider options checkbox2693 elseif ( $_POST[‘slider_check_field’] == 0) {2694 break;2695 }26962697 //if we are in the slider creation case, the selected slider has to be the new one!2698 if (!empty( $new_slider_name))2699 break;27002701 //check if we have something to save2702 $post_slider_name = esc_attr( $tcvalue );27032704 //check if we have an input and if we are not in the slider creation case2705 if (!empty( $post_slider_name)) {27062707 $post_slider_name = wp_filter_nohtml_kses( $post_slider_name );2708 //looks for a previous slider entry and delete it.2709 //Important : we check if the slider has slides first!2710 foreach ( $czr_options[‘tc_sliders’] as $slider_name => $slider) {2711 foreach ( $slider as $key => $tc_post) {27122713 //clean empty values if necessary2714 if ( is_null( $czr_options[‘tc_sliders’][$slider_name][$key])) {2715 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2716 }27172718 //clean slides with no images2719 $slide_img = wp_get_attachment_image( $czr_options[‘tc_sliders’][$slider_name][$key]);2720 if (isset($slide_img) && empty($slide_img)) {2721 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2722 }27232724 //delete previous slider entries for this post2725 if ( $tc_post == $post_ID ) {2726 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2727 }27282729 }//end for each2730 }2731 //update DB with clean option table2732 update_option( ‘tc_theme_options’ , $czr_options );27332734 //check if the selected slider is empty and set it as array2735 if( empty( $czr_options[‘tc_sliders’][$post_slider_name]) ) {2736 $czr_options[‘tc_sliders’][$post_slider_name] = array();2737 }27382739 //push new post value for the slider and write in DB2740 array_push( $czr_options[‘tc_sliders’][$post_slider_name], $post_ID);2741 update_option( ‘tc_theme_options’ , $czr_options );2742 }//end if !empty( $post_slider_name)27432744 //No slider selected2745 else {2746 //looks for a previous slider entry and delete it2747 foreach ( $czr_options[‘tc_sliders’] as $slider_name => $slider) {2748 foreach ( $slider as $key => $tc_post) {2749 //clean empty values if necessary2750 if ( is_null( $czr_options[‘tc_sliders’][$slider_name][$key]))2751 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2752 //delete previous slider entries for this post2753 if ( $tc_post == $post_ID )2754 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2755 }2756 }2757 //update DB with clean option table2758 update_option( ‘tc_theme_options’ , $czr_options );2759 }2760 break;2761 }//end switch2762 }//end foreach27632764 //POST META FIELDS2765 //set up the fields array2766 $tc_slider_fields = array(2767 //posts & pages2768 ‘post_slider_name’ => ‘post_slider_key’ ,2769 ‘post_slider_check_field’ => ‘post_slider_check_key’ ,2770 //attachments2771 ‘slider_check_field’ => ‘slider_check_key’ ,2772 );27732774 do_action( “__before_ajax_save_slider_{$tc_post_type}", $_POST, $tc_slider_fields );2775 //sanitize user input by looping on the fields2776 foreach ( $tc_slider_fields as $tcid => $tckey) {2777 if ( isset( $_POST[$tcid])) {2778 switch ( $tckey) {2779 //different sanitizations2780 //the slider name custom field for a post/page2781 case ‘post_slider_key’ :2782 $mydata = esc_attr( $_POST[$tcid] );2783 //Does the selected slider still exists in options? (we first check if the selected slider is not empty)2784 if(!empty( $mydata) && !isset( $czr_options[‘tc_sliders’][$mydata]))2785 break;27862787 //write in DB2788 add_post_meta( $post_ID, $tckey, $mydata, true) or2789 update_post_meta( $post_ID, $tckey , $mydata);2790 break;279127922793 //inserted/updated in all cases2794 case 'post_slider_check_key’:2795 case 'slider_check_key’:2796 $mydata = esc_attr( $_POST[$tcid] );2797 //write in DB2798 add_post_meta( $post_ID, $tckey, $mydata, true) or2799 update_post_meta( $post_ID, $tckey , $mydata);28002801 //check if we are in the attachment screen AND slider unchecked2802 if( $tckey == ‘slider_check_key’ && esc_attr( $_POST[$tcid] ) == 0) {28032804 //if we uncheck the attachement slider, looks for a previous entry and delete it.2805 //Important : we check if the slider has slides first!2806 if ( isset( $czr_options[‘tc_sliders’])) {2807 foreach ( $czr_options[‘tc_sliders’] as $slider_name => $slider) {2808 foreach ( $slider as $key => $tc_post) {2809 //clean empty values if necessary2810 if ( is_null( $czr_options[‘tc_sliders’][$slider_name][$key]))2811 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2812 //delete previous slider entries for this post2813 if ( $tc_post == $post_ID )2814 unset( $czr_options[‘tc_sliders’][$slider_name][$key]);2815 }2816 }2817 }2818 //update DB with clean option table2819 update_option( ‘tc_theme_options’ , $czr_options );28202821 }//endif;28222823 break;2824 }//end switchendif;2825 }//end if ( isset( $_POST[$tcid])) {2826 }//end foreach2827 //attachments2828 if( $tc_post_type == ‘attachment’ )2829 $this->czr_fn_slide_save( $post_ID );28302831 do_action( “__after_ajax_save_slider_{$tc_post_type}", $_POST, $tc_slider_fields );2832 }//function2833283428352836283728382839 /*2840 ----------------------------------------------------------------2841 -------- AJAX CALL BACK FUNCTION (post and attachment) ---------2842 ----------------------------------------------------------------2843 */28442845 /**2846 * Global slider ajax call back function : 1-Saves options and fields, 2-Renders2847 * Used in post or attachment context => uses post_slider var to check the context2848 * Works along with tc_ajax_slider.js2849 * @package Customizr2850 * @since Customizr 2.02851 */2852 function czr_fn_slider_cb() {28532854 $nonce = $_POST[‘SliderCheckNonce’];2855 // check if the submitted nonce matches with the generated nonce we created earlier2856 if ( ! wp_verify_nonce( $nonce, ‘tc-slider-check-nonce’ ) ) {2857 die();2858 }28592860 Try{2861 //get the post_id with the hidden input field2862 $tc_post_id = $_POST[‘tc_post_id’];28632864 //save $_POST var in DB2865 $this->czr_fn_slider_ajax_save( $tc_post_id);28662867 //check if we are in the post or attachment screen and select the appropriate rendering2868 //we use the post_slider var defined in tc_ajax_slider.js2869 if ( isset( $_POST[‘tc_post_type’])) {2870 if( $_POST[‘tc_post_type’] == ‘post’ ) {2871 $this->czr_fn_get_post_slider_infos( $tc_post_id );2872 }2873 else {2874 $this->czr_fn_get_attachment_slider_infos( $tc_post_id );2875 }2876 }2877 //echo $_POST[‘slider_id’];2878 } catch (Exception $e){2879 exit;2880 }2881 exit;2882 }2883288428852886288728882889 /**2890 * Loads the necessary scripts and stylesheets to display slider options2891 * @package Customizr2892 * @since Customizr 1.02893 * @hook czr_slider_metabox_added2894 */2895 function czr_fn_slider_admin_scripts( $post ) {28962897 $_min_version = ( !$this->_minify_resources ) ? ‘’ : ‘.min’;289828992900 //load scripts only for creating and editing slides options in pages and posts2901 if ( did_action( ‘tc_attachment_metabox_added’ ) ) {2902 wp_enqueue_script( ‘jquery-ui-sortable’ );2903 }290429052906 do_action( ‘tc_enqueue_ajax_slider_before’ );29072908 //ajax refresh for slider options2909 wp_enqueue_script( ‘czr_ajax_slider’ ,2910 sprintf(‘%1$sback/js/tc_ajax_slider%2$s.js’ , CZR_BASE_URL . CZR_ASSETS_PREFIX, $_min_version ),2911 array( ‘jquery’ ),2912 ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? CUSTOMIZR_VER . time() : CUSTOMIZR_VER,2913 true2914 );29152916 // Tips to declare javascript variables http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/#bad-ways2917 wp_localize_script( ‘czr_ajax_slider’ , ‘SliderAjax’ , array(2918 // URL to wp-admin/admin-ajax.php to process the request2919 //’ajaxurl’ => admin_url( ‘admin-ajax.php’ ),2920 // generate a nonce with a unique ID “myajax-post-comment-nonce"2921 // so that you can check it later when an AJAX request is sent2922 ‘SliderNonce’ => wp_create_nonce( ‘tc-slider-nonce’ ),2923 ‘SliderCheckNonce’ => wp_create_nonce( ‘tc-slider-check-nonce’ ),2924 )2925 );29262927 //thickbox2928 wp_admin_css( ‘thickbox’ );2929 add_thickbox();29302931 //sortable stuffs2932 wp_enqueue_style( ‘sortablecss’ ,2933 sprintf(‘%1$sback/css/tc_sortable%2$s.css’ , CZR_BASE_URL . CZR_ASSETS_PREFIX, $_min_version )2934 );29352936 //wp built-in color picker style and script2937 //Access the global $wp_version variable to see which version of WordPress is installed.2938 global $wp_version;29392940 //If the WordPress version is greater than or equal to 3.5, then load the new WordPress color picker.2941 if ( 3.5 <= $wp_version ){2942 //Both the necessary css and javascript have been registered already by WordPress, so all we have to do is load them with their handle.2943 wp_enqueue_style( ‘wp-color-picker’ );2944 wp_enqueue_script( ‘wp-color-picker’ );2945 // load the minified version of custom script2946 wp_enqueue_script( ‘cp_demo-custom’ ,2947 sprintf(‘%1$sback/js/color-picker%2$s.js’ , CZR_BASE_URL . CZR_ASSETS_PREFIX , $_min_version ),2948 array( ‘jquery’ , ‘wp-color-picker’ ),2949 true2950 );2951 }2952 //If the WordPress version is less than 3.5 load the older farbtasic color picker.2953 else {2954 //As with wp-color-picker the necessary css and javascript have been registered already by WordPress, so all we have to do is load them with their handle.2955 wp_enqueue_style( ‘farbtastic’ );2956 wp_enqueue_script( ‘farbtastic’ );2957 // load the minified version of custom script2958 wp_enqueue_script(2959 ‘cp_demo-custom’ ,2960 sprintf(‘%1$sback/js/color-picker%2$s.js’ , CZR_BASE_URL . CZR_ASSETS_PREFIX, $_min_version ),2961 array( ‘jquery’ , ‘farbtastic’ ),2962 ( defined(‘WP_DEBUG’) && true === WP_DEBUG ) ? CUSTOMIZR_VER . time() : CUSTOMIZR_VER,2963 true2964 );2965 }29662967 do_action( ‘tc_enqueue_ajax_slider_after’ );29682969 }29702971 /**2972 * Loads the necessary scripts for the post formats metaboxes2973 * @package Customizr2974 * @since Customizr 4.02975 * @hook czr_post_formats_metabox_added2976 */29772978 function czr_fn_post_formats_admin_scripts( $post ) {29792980 $_ext = $this->_minify_resources ? ‘.min.js’ : '.js’;29812982 wp_enqueue_script( ‘czr-post-formats’ ,2983 sprintf(‘%1$sback/js/czr_post_formats%2$s’ , CZR_BASE_URL . CZR_ASSETS_PREFIX, $_ext ),2984 array( 'jquery’, ‘underscore’ ),2985 $this->_resouces_version,2986 $in_footer = true29872988 );29892990 wp_localize_script( 'czr-post-formats’,2991 ‘CZRPostFormatsParams’ ,2992 array(2993 ‘postFormatSections’ => $this->czr_fn_get_post_meta_boxes_map(),2994 ‘currentPostFormat’ => get_post_format( $post ),2995 )2996 );29972998 }299930003001300230033004 /*3005 ----------------------------------------------------------------3006 ------------- ATTACHMENT FIELDS FILTER IF WP < 3.5 -------------3007 ----------------------------------------------------------------3008 */3009 function czr_fn_attachment_filter( $form_fields, $post = null) {3010 $this->czr_fn_attachment_slider_box ( $post);3011 return $form_fields;3012 }301330143015 function czr_fn_attachment_save_filter( $post, $attachment ) {3016 if ( isset( $_POST[‘tc_post_id’]))3017 $postid = $_POST[‘tc_post_id’];30183019 $this->czr_fn_slide_save( $postid );30203021 return $post;3022 }3023302430253026 /*3027 ----------------------------------------------------------------3028 ---------------------- STATIC FIELDS VIEWS ---------------------3029 ----------------------------------------------------------------3030 */3031 /**3032 * Build title element html3033 *3034 * @package Customizr3035 */3036 public static function czr_fn_title_view( $args ) {30373038 $defaults = array(3039 ‘title_tag’ => 'h4’,3040 ‘wrapper_class’ => 'meta-box-item-title’,3041 ‘wrapper_tag’ => 'div’,3042 ‘title_text’ => '’,3043 ‘echo’ => 1,3044 ‘boxed’ => 1,3045 );30463047 $args = wp_parse_args( $args, $defaults );3048 extract($args);30493050 $content = sprintf( '<%1$s>%2$s</%1$s>’, $title_tag, $title_text );30513052 $html = $boxed ? CZR_meta_boxes::czr_fn_wrapper_view(3053 compact( 'content’, 'wrapper_tag’, ‘wrapper_class’)3054 ) : $content;30553056 if ( ! $echo )3057 return $html;30583059 echo $html;30603061 }306230633064 /**3065 * Build checkbox element html3066 *3067 * @package Customizr3068 */3069 public static function czr_fn_checkbox_view( $args ) {30703071 $defaults = array(3072 ‘input_name’ => '’,3073 ‘input_class’ => 'czr-toggle-check__input’,3074 ‘input_state’ => '’,3075 ‘echo’ => 1,3076 ‘boxed’ => 1,3077 ‘input_type’ => 'checkbox’,3078 ‘input_value’ => '1’,3079 ‘content_before’ => '’,3080 );30813082 $args = wp_parse_args( $args, $defaults );3083 extract( $args );30843085 CZR_meta_boxes::czr_fn_generic_input_view( array_merge( $args, array(3086 ‘content_before’ => $content_before . '<input name="’. $input_name .’” type="hidden” value = “0” /><span class="czr-toggle-check">’,3087 ‘custom_args’ => checked( $input_state, $current = true, $c_echo = false),3088 ‘content_after’ => '<span class="czr-toggle-check__track"></span><span class="czr-toggle-check__thumb"></span></span>’3089 )));3090 }3091309230933094 /**3095 * Build selectbox element html3096 *3097 * @package Customizr3098 */3099 public static function czr_fn_selectbox_view( $args ) {3100 $defaults = array(3101 ‘select_name’ => '’,3102 ‘select_class’ => '’,3103 ‘echo’ => 1,3104 ‘boxed’ => 1,3105 ‘content_before’ => '’,3106 ‘content_after’ => '’,3107 ‘choices’ => array(),3108 ‘selected’ => '’,3109 ‘wrapper_tag’ => 'div’,3110 ‘wrapper_class’ => 'meta-box-item-content’,3111 );31123113 $args = wp_parse_args( $args, $defaults );3114 extract($args);31153116 if ( ! $choices ) return;31173118 $select_id = isset($select_id) ? $select_id : $select_name;31193120 $options_html = '’;31213122 foreach( $choices as $key => $label )3123 $options_html .= sprintf('<option value=%1$s %2$s>%3$s</option>’,3124 esc_attr( $key ),3125 selected( $selected, esc_attr( $key ), $s_echo = false ),3126 $label3127 );31283129 $content = sprintf('<select name="%1$s” id ="%2$s">%3$s</select>’,3130 $select_name,3131 $select_id,3132 $options_html3133 );31343135 $content = $content_before . $content . $content_after;31363137 $html = $boxed ? CZR_meta_boxes::czr_fn_wrapper_view(3138 compact( 'content’, 'wrapper_tag’, ‘wrapper_class’)3139 ) : $content;31403141 $html = ! ( isset($title) && is_array( $title ) && ! empty( $title ) ) ? $html :3142 sprintf( “%s%s",3143 CZR_meta_boxes::czr_fn_title_view( array_merge($title, array( ‘echo’ => 0 ) ) ),3144 $html3145 );31463147 if ( ! $echo )3148 return $html;31493150 echo $html ;3151 }315231533154 /**3155 * Build generic input element html3156 *3157 * @package Customizr3158 */3159 public static function czr_fn_generic_input_view( $args ) {3160 $defaults = array(3161 ‘input_name’ => '’,3162 ‘input_class’ => 'widefat’,3163 ‘input_type’ => 'text’,3164 ‘input_value’ => '0’,3165 ‘custom_args’ => '’,3166 ‘echo’ => 1,3167 ‘boxed’ => 1,3168 ‘content_before’ => '’,3169 ‘content_after’ => '’,3170 ‘wrapper_tag’ => 'div’,3171 ‘wrapper_class’ => 'meta-box-item-content’,3172 );31733174 $args = wp_parse_args( $args, $defaults );3175 extract($args);31763177 $input_id = isset($input_id) ? $input_id : $input_name;31783179 $content = sprintf('<input name="%1$s” id="%2$s” value="%3$s” %4$s class="%5$s" type="%6$s" />’,3180 esc_attr( $input_name ),3181 esc_attr( $input_id ),3182 esc_attr( $input_value ),3183 $custom_args,3184 $input_class,3185 $input_type3186 );31873188 $content = $content_before . $content . $content_after;31893190 $html = $boxed ? CZR_meta_boxes::czr_fn_wrapper_view(3191 compact( 'content’, 'wrapper_tag’, ‘wrapper_class’)3192 ) : $content;31933194 $html = ! ( isset($title) && is_array( $title ) && ! empty( $title ) ) ? $html :3195 sprintf( “%s%s",3196 CZR_meta_boxes::czr_fn_title_view( array_merge($title, array( ‘echo’ => 0 ) ) ),3197 $html3198 );31993200 if ( ! $echo )3201 return $html;32023203 echo $html ;3204 }320532063207 /**3208 * Build generic input element html3209 *3210 * @package Customizr3211 */3212 public static function czr_fn_textarea_view( $args ) {3213 $defaults = array(3214 ‘input_name’ => '’,3215 ‘input_class’ => 'widefat’,3216 ‘input_value’ => '0’,3217 ‘custom_args’ => '’,3218 ‘echo’ => 1,3219 ‘boxed’ => 1,3220 ‘content_before’ => '’,3221 ‘content_after’ => '’,3222 ‘rows’ => '5’,3223 ‘cols’ => '40’,3224 ‘wrapper_tag’ => 'div’,3225 ‘wrapper_class’ => 'meta-box-item-content’,3226 );32273228 $args = wp_parse_args( $args, $defaults );3229 extract($args);32303231 $input_id = isset($input_id) ? $input_id : $input_name;32323233 $content = sprintf('<textarea name="%1$s” d="%2$s" %4$s class="%5$s" type="%6$s" rows="%6$s" cols="%7$s">%3$s</textarea>’,3234 esc_attr( $input_name ),3235 esc_attr( $input_id ),3236 esc_attr( $input_value ),3237 $custom_args,3238 $input_class,3239 $rows,3240 $cols3241 );32423243 $content = $content_before . $content . $content_after;32443245 $html = $boxed ? CZR_meta_boxes::czr_fn_wrapper_view(3246 compact( 'content’, 'wrapper_tag’, ‘wrapper_class’)3247 ) : $content;32483249 $html = ! ( isset($title) && is_array( $title ) && ! empty( $title ) ) ? $html :3250 sprintf( "%s%s",3251 CZR_meta_boxes::czr_fn_title_view( array_merge($title, array( ‘echo’ => 0 ) ) ),3252 $html3253 );32543255 if ( ! $echo )3256 return $html;32573258 echo $html ;3259 }326032613262 /**3263 * Build generic content wrapper html3264 *3265 * @package Customizr3266 */3267 public static function czr_fn_wrapper_view( $args ) {3268 $defaults = array(3269 ‘wrapper_tag’ => 'div’,3270 ‘wrapper_class’ => 'meta-box-item-content’,3271 ‘echo’ => false,3272 ‘content’ => '’3273 );32743275 $args = wp_parse_args( $args, $defaults );3276 extract($args);32773278 $html = sprintf('<%1$s class="%2$s">%3$s</%1$s>’,3279 $wrapper_tag,3280 $wrapper_class,3281 $content3282 );32833284 if ( ! $echo )3285 return $html;3286 echo $html;3287 }32883289 }//end of class3290endif;32913292?>