/**
  * Prints the box content.
  *
  * @since 1.0.0
  * @param object $post    Current post object.
  * @param array  $metabox
  */
 public function callback_metabox($post, $metabox)
 {
     if (!class_exists('Cherry_Interface_Builder')) {
         return;
     }
     // open core UI wrappers
     echo '<div class="cherry-ui-core">';
     // Add an nonce field so we can check for it later.
     wp_nonce_field(plugin_basename(__FILE__), 'cherry_team_options_meta_nonce');
     $builder = new Cherry_Interface_Builder(array('name_prefix' => CHERRY_TEAM_POSTMETA, 'pattern' => 'inline', 'class' => array('section' => 'single-section')));
     foreach ($metabox['args'] as $field) {
         // Check if set the 'id' value for custom field. If not - don't add field.
         if (!isset($field['id'])) {
             continue;
         }
         $field['value'] = Cherry_Team::get_meta($post->ID, $field['id'], $field['value']);
         echo $builder->add_form_item($field);
     }
     /**
      * Fires after testimonial fields of metabox.
      *
      * @since 1.0.0
      * @param object $post                 Current post object.
      * @param array  $metabox
      * @param string CHERRY_TEAM_POSTMETA Name for 'meta_key' value in the 'wp_postmeta' table.
      */
     do_action('cherry_team_metabox_after', $post, $metabox, CHERRY_TEAM_POSTMETA);
     // close core UI wrappers
     echo '</div>';
 }
 /**
  * Displays a meta box of radio selectors on the post editing screen, which allows theme users to select
  * the layout they wish to use for the specific post.
  *
  * @since  4.0.0
  * @param  object $post    The post object currently being edited.
  * @param  array  $metabox Specific information about the meta box being loaded.
  * @return void
  */
 public function callback_metabox($post, $metabox)
 {
     // Get the current post's layout.
     $post_layout = $this->get_post_layout($post->ID);
     $args = array('id' => 'layout', 'type' => 'radio', 'value' => $post_layout, 'display_input' => false, 'options' => $metabox['args']);
     wp_nonce_field(basename(__FILE__), 'cherry-layouts-nonce');
     $builder = new Cherry_Interface_Builder(array('name_prefix' => 'cherry', 'pattern' => 'inline', 'class' => array('section' => 'single-section')));
     printf('<div class="post-layout">%s</div>', $builder->add_form_item($args));
     /**
      * Fires after `Layouts` fields of metabox.
      *
      * @since 4.0.0
      * @param object $post
      * @param array  $metabox
      */
     do_action('cherry_layouts_metabox_after', $post, $metabox);
 }
 /**
  * Displays a meta box of radio selectors on the post editing screen, which allows theme users to select
  * the layout they wish to use for the specific post.
  *
  * @since  4.0.0
  * @param  object $post    The post object currently being edited.
  * @param  array  $metabox Specific information about the meta box being loaded.
  * @return void
  */
 public function callback_metabox($post, $metabox)
 {
     $bg_defaults = array('image' => '', 'color' => '', 'repeat' => '', 'position' => '', 'attachment' => '');
     // Get the current post header bg
     $header_bg = $this->get_post_style($post->ID, 'header-background', $bg_defaults);
     $fields = array(array('id' => 'header-background', 'title' => __('Header background', 'cherry'), 'type' => 'background', 'value' => $header_bg));
     $fields = apply_filters('cherry_post_style_metabox_fields', $fields);
     wp_nonce_field(basename(__FILE__), 'cherry-style-nonce');
     $builder = new Cherry_Interface_Builder(array('name_prefix' => 'cherry-style', 'pattern' => 'inline', 'class' => array('section' => 'single-section')));
     $content = '';
     foreach ($fields as $field) {
         $content .= $builder->add_form_item($field);
     }
     printf('<div class="cherry-ui-core post-style">%s</div>', $content);
     /**
      * Fires after `Style` fields of metabox.
      *
      * @since 4.0.0
      * @param object $post
      * @param array  $metabox
      */
     do_action('cherry_style_metabox_after', $post, $metabox);
 }
 public function enqueue_styles()
 {
     $screen = get_current_screen();
     if (!empty($screen->post_type) && 'portfolio' === $screen->post_type) {
         $option_inteface_builder = new Cherry_Interface_Builder();
         $option_inteface_builder->enqueue_builder_styles();
         wp_enqueue_style('portfolio-admin-style', trailingslashit(CHERRY_PORTFOLIO_URI) . 'admin/assets/css/admin-style.css', array(), CHERRY_PORTFOLIO_VERSION);
     }
 }
 public function format_metabox_builder($post_id = null, $format = 'standart')
 {
     $output = '';
     $settings_field = $this->format_settings($format);
     foreach ($settings_field as $settings) {
         // Get current post meta data.
         $post_meta = get_post_meta($post_id, CHERRY_PORTFOLIO_POSTMETA, true);
         if (!empty($post_meta) && isset($post_meta[$settings['id']])) {
             $field_value = $post_meta[$settings['id']];
         } else {
             $field_value = $settings['value'];
         }
         $settings['value'] = $field_value;
         $builder = new Cherry_Interface_Builder(array('name_prefix' => CHERRY_PORTFOLIO_POSTMETA, 'pattern' => 'inline', 'class' => array('section' => 'single-section')));
         $output .= $builder->add_form_item($settings);
     }
     printf('<div class="%1$s cherry-ui-core">%2$s</div>', 'settings-item ' . $format . '-post-format-settings', $output);
 }
Exemplo n.º 6
0
 /**
  * Displays a meta box of radio selectors on the post editing screen, which allows theme users to select
  * the grid type they wish to use for the specific post.
  *
  * @since  4.0.0
  * @param  object $post    The post object currently being edited.
  * @param  array  $metabox Specific information about the meta box being loaded.
  * @return void
  */
 public function callback_metabox($post, $metabox)
 {
     // Get the current post's grid type.
     $post_grid_type = $this->get_post_grid_type($post->ID);
     wp_nonce_field(basename(__FILE__), 'cherry-grid-type-nonce');
     $builder = new Cherry_Interface_Builder(array('name_prefix' => 'grid-type', 'pattern' => 'inline', 'class' => array('section' => 'single-section')));
     $builder->enqueue_builder_scripts();
     $builder->enqueue_builder_styles();
     $output = '';
     foreach ($this->options as $id => $item) {
         $args = array('id' => $id, 'type' => 'radio', 'value' => $post_grid_type[$id], 'display_input' => false, 'options' => $metabox['args'][$id]);
         $output .= sprintf('<div class="post-grid-type_col"><div class="post-grid-type_col__inner"><h4 class="cherry-title">%1$s</h4>%2$s</div></div>', $item['name'], $builder->add_form_item($args));
     }
     printf('<div class="post-grid-type_container"><div class="post-grid-type_row">%s</div><div class="clear"></div></div>', $output);
     /**
      * Fires after `Grid Type` fields of metabox.
      *
      * @since 4.0.0
      * @param object $post    The post object
      * @param array  $metabox Metabox information.
      */
     do_action('cherry_grid_type_metabox_after', $post, $metabox);
 }
        /**
         *
         * @since 4.0.0
         */
        public static function cherry_options_page_build()
        {
            global $cherry_options_framework;
            $option_inteface_builder = new Cherry_Interface_Builder();
            $option_inteface_builder->enqueue_builder_scripts();
            $option_inteface_builder->enqueue_builder_styles();
            $section_index = 0;
            $cherry_options = $cherry_options_framework->get_current_settings();
            $cherry_options = self::child_priority_sorting($cherry_options);
            $cherry_options = self::priority_sorting($cherry_options);
            ?>
			<?php 
            settings_errors('cherry-options');
            ?>
				<form id="cherry-options" class="cherry-ui-core" method="post">
					<?php 
            settings_fields('cherry-options');
            ?>
					<input class="active-section-field" type="hidden" name="active_section" value="">
					<div class="cherry-sections-wrapper">
						<ul class="cherry-option-section-tab vertical-tabs_ vertical-tabs_width_mid_">
							<?php 
            foreach ($cherry_options as $section_key => $section_value) {
                $parent = !empty($section_value['parent']) ? $section_value['parent'] : '';
                $parent !== '' ? $subClass = 'subitem' : ($subClass = '');
                $priority_value = $section_value['priority'];
                ?>
								<li class="tabitem-<?php 
                echo $section_index;
                ?>
 <?php 
                echo $subClass;
                ?>
 <?php 
                echo $parent;
                ?>
" data-section-name="<?php 
                echo $section_key;
                ?>
"><a href="javascript:void(0)"><i class="<?php 
                echo $section_value["icon"];
                ?>
"></i><span><?php 
                echo $section_value["name"];
                ?>
</span></a></li>
							<?php 
                $section_index++;
            }
            ?>
						</ul>
						<div class="cherry-option-group-list"></div>
						<div class="clear"></div>
					</div>
					<div class="cherry-submit-wrapper">
						<div class="cherry-options-export-import">
							<div class="wrap-cherry-import-options">
								<a href="javascript:void(0)" id="cherry-export-import-options" class="button button-default_">
									<?php 
            _e('Export/Import', 'cherry');
            ?>
								</a>
							</div>
							<div class="wrap-cherry-default-options-backup">
								<a href="#" id="cherry-default-options-backup" class="button button-primary_">
									<?php 
            _e('Default options', 'cherry');
            ?>
									<div class="cherry-spinner-wordpress spinner-wordpress-type-2"><span class="cherry-inner-circle"></span></div>
								</a>
							</div>
						</div>
						<div id="wrap-cherry-save-options">
							<a href="javascript:void(0)" id="cherry-save-options" class="button button-secondary_">
								<?php 
            echo __('Save options', 'cherry');
            ?>
								<div class="cherry-spinner-wordpress spinner-wordpress-type-2"><span class="cherry-inner-circle"></span></div>
							</a>
						</div>
						<div id="wrap-cherry-restore-section">
							<a href="javascript:void(0)" id="cherry-restore-section" class="button button-primary_">
								<?php 
            echo __('Restore section', 'cherry');
            ?>
							</a>
						</div>
						<div id="wrap-cherry-restore-options">
							<a href="javascript:void(0)" id="cherry-restore-options" class="button button-primary_">
								<?php 
            echo __('Restore options', 'cherry');
            ?>
							</a>
						</div>
					</div>
				</form>
				<div class="export-import-wrapper cherry-ui-core">
					<div class="export-control">
						<h4><?php 
            _e('Export', 'cherry');
            ?>
</h4>
						<a href="<?php 
            echo esc_url(self::$options_export_url);
            ?>
" id="cherry-export-options" class="button button-default_"><?php 
            _e('Export', 'cherry');
            ?>
</a>
						<?php 
            wp_nonce_field('cherry_partial_export', 'partial-export-nonce', false);
            ?>
						<a href="javascript:void(0)" id="cherry-partial-export-options" class="button button-default_"><?php 
            _e('Partial export', 'cherry');
            ?>
<div class="cherry-spinner-wordpress spinner-wordpress-type-3"><span class="cherry-inner-circle"></span></div></a>
						<div class="use-statics-wrap">
						<?php 
            $ui_checkbox = new UI_Checkbox(array('id' => 'cherry-export-use-static-setting', 'name' => 'cherry-export-use-static-setting', 'value' => array(), 'options' => array('use-statics' => __('Attach statics settings', 'cherry')), 'class' => 'cherry-export-use-static-setting'));
            echo $ui_checkbox->render();
            ?>
						</div>
					</div>
					<div class="import-control">
						<h4><?php 
            _e('Import', 'cherry');
            ?>
</h4>
						<?php 
            wp_nonce_field('cherry_import_options', 'import-options-nonce', false);
            ?>
						<input type="hidden" autocomplete="off" id="cherry-import-options-file-id" value="">
						<input type="hidden" autocomplete="off" id="cherry-import-options-file-type" value="">
						<a href="#" id="cherry-import-options-file" class="button button-default_"><?php 
            _e('Select file', 'cherry');
            ?>
</a>
						<a href="#" id="cherry-import-options-start" class="button button-primary_"><?php 
            _e('Start import', 'cherry');
            ?>
<div class="cherry-spinner-wordpress spinner-wordpress-type-2"><span class="cherry-inner-circle"></span></div></a>
						<div class="cherry-import-file-name"></div>
					</div>
					<div class="clear"></div>
				</div>
				<div id="restore-options-confirm" class="confirm-message" title="<?php 
            echo __('Are you sure?', 'cherry');
            ?>
">
					<span class="dashicons dashicons-info"></span>
					<p><?php 
            echo __('Current options will be reset to the defaults, page will be refreshed.', 'cherry');
            ?>
</p>
				</div>
				<div id="restore-section-confirm" class="confirm-message" title="<?php 
            echo __('Are you sure?', 'cherry');
            ?>
">
					<span class="dashicons dashicons-info"></span>
					<p><?php 
            echo __('Active section will be reset to the defaults, page will be refreshed.', 'cherry');
            ?>
</p>
				</div>
				<?php 
        }
 /**
  * Returns the instance.
  *
  * @since  1.0.0
  * @access public
  * @return object
  */
 public static function get_instance($core, $args)
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self($core, $args);
     }
     return self::$instance;
 }