コード例 #1
0
 /**
  * Render Template Regions metabox.
  * 
  * @since 1.0.0
  * @access public
  * @param object $post 
  */
 public function render_template_regions($post)
 {
     // Add an nonce field so we can check for it later.
     wp_nonce_field('tf_template_option_custom_box', 'tf_template_option_custom_box_nonce');
     $fields = array('template_part_caption' => array('type' => 'separator', 'meta' => array('html' => sprintf(__('<h4>Select a <a href="%s">Template Part</a> for each region: Header, Sidebar, and Footer.</h4>', 'themify-flow'), admin_url('edit.php?post_type=tf_template_part')))), 'tf_template_region_header' => array('type' => 'template_part_select', 'label' => __('Header', 'themify-flow'), 'show_extra_link' => false), 'tf_template_region_sidebar' => array('type' => 'template_part_select', 'label' => __('Sidebar', 'themify-flow'), 'show_extra_link' => false), 'tf_template_region_footer' => array('type' => 'template_part_select', 'label' => __('Footer', 'themify-flow'), 'show_extra_link' => false));
     $data = TF_Model::get_field_exist_values($fields, $post->ID);
     /* not used anymore
     		if ( count( $data ) > 0 ) {
     			foreach( $data as $key => $shortcode ) {
     				preg_match('/.*slug="(.*)"/i', $shortcode, $slug );
     				$data[ $key ] = isset( $slug[1] ) ? $slug[1] : '';
     			}
     		}*/
     echo '<div class="tf_interface">';
     echo TF_Form::render($fields, $data);
     echo '</div>';
 }
コード例 #2
0
 /**
  * Render Template Options metabox.
  * 
  * @since 1.0.0
  * @access public
  * @param object $post 
  */
 public function render_template_part_option($post)
 {
     // Add an nonce field so we can check for it later.
     wp_nonce_field('tf_template_part_option_custom_box', 'tf_template_part_option_custom_box_nonce');
     $fields = $this->fields();
     unset($fields['tf_template_part_name']);
     $data = TF_Model::get_field_exist_values($fields, $post->ID);
     echo '<div class="tf_interface">';
     echo TF_Form::render($fields, $data);
     echo '</div>';
 }
コード例 #3
0
 /**
  * Render duplicate form options in Lightbox via Hooks
  * 
  * @since 1.0.0
  * @access public
  */
 public function render_duplicate_form()
 {
     $theme_id = (int) $_POST['postid'];
     $theme = get_post($theme_id);
     $data = get_post_meta($theme_id, 'theme_info', true);
     $data['tf_theme_name'] = $theme->post_title . ' Copy';
     $fields = $this->fields();
     if (isset($fields['tf_import_base_template_and_part'])) {
         unset($fields['tf_import_base_template_and_part']);
     }
     echo TF_Form::open(array('id' => 'tf_theme_duplicate_form'));
     wp_nonce_field('tf_theme_export_nonce', 'nonce_field');
     echo sprintf('<input type="hidden" name="_theme_id" value="%d">', $theme_id);
     echo TF_Form::render($fields, $data);
     echo TF_Form::submit_button(__('Duplicate', 'themify-flow'));
     echo TF_Form::close();
 }
コード例 #4
0
    public function load_tmpl()
    {
        if (TF_Model::is_tf_editor_active() || is_admin()) {
            foreach ($this->elements as $element) {
                ?>
			<script type="text/html" id="tmpl-tf_active_element_<?php 
                echo $element->slug;
                ?>
">
				<div class="tf_active_module" data-tf-module="<?php 
                echo esc_attr($element->slug);
                ?>
" data-tf-content="<?php 
                echo esc_attr($element->get_content_field());
                ?>
">
					<div class="tf_back_module_top">
						<div class="tf_left">
							<span class="tf_back_active_module_title"><?php 
                echo esc_attr($element->name);
                ?>
</span>
						</div>
						<!-- /tf_left -->
						<div class="tf_right">
							<a href="#" class="tf_module_btn tf_toggle_module"></a>
							<a href="#" class="tf_module_btn tf_delete_module"></a>
						</div>
						<!-- /tf_right -->
					</div>
					<!-- /tf_back_module_top -->
					<div class="tf_back_active_module_content">
						<?php 
                echo TF_Form::render_element($element->fields());
                ?>
					</div>
					<!-- /tf_back_module_content -->
				</div>
			</script>
			<?php 
            }
        }
    }
コード例 #5
0
    /**
     * Filter shortcode to added editable markup for module edit.
     * 
     * @since 1.0.0
     * @access public
     * @param string $output 
     * @param string $module_slug 
     * @param array $atts 
     * @return string
     */
    public function shortcode_element_render($output, $element_slug, $atts, $content)
    {
        global $TF, $tf_module_elements;
        if ($TF->in_builder_lightbox) {
            $element = $tf_module_elements->get_element($element_slug);
            if (!empty($content)) {
                $atts = array_merge($atts, array($element->get_content_field() => $content));
            }
            $form = TF_Form::render_element($element->fields(), $atts);
            $output = sprintf('<div class="tf_active_module" data-tf-module="%s" data-tf-content="%s">
					<div class="tf_back_module_top">
						<div class="tf_left">
							<span class="tf_back_active_module_title">%s</span>
						</div>
						<!-- /tf_left -->
						<div class="tf_right">
							<a href="#" class="tf_module_btn tf_toggle_module"></a>
							<a href="#" class="tf_module_btn tf_delete_module"></a>
						</div>
						<!-- /tf_right -->
					</div>
					<!-- /tf_back_module_top -->
					<div class="tf_back_active_module_content">
						%s
					</div>
					<!-- /tf_back_module_content -->
				</div>', $element_slug, esc_attr($element->get_content_field()), esc_attr($element->name), $form);
        }
        return $output;
    }
コード例 #6
0
 /**
  * Fires to render row option form.
  * 
  * @since 1.0.0
  * @access public
  * @param string $method Form state method (add|edit|delete)
  */
 public function render_row_option_form($method)
 {
     $label_submit_btn = 'add' == $method ? __('Add', 'themify-flow') : __('Update', 'themify-flow');
     $data = array();
     $shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : '';
     $atts = isset($_POST['shortcode_params']) ? $_POST['shortcode_params'] : array();
     $shortcode_id = isset($atts['sc_id']) ? $atts['sc_id'] : TF_Model::generate_block_id();
     $template_id = isset($_POST['template_id']) ? $_POST['template_id'] : 0;
     $mode = isset($_POST['mode']) ? $_POST['mode'] : 'frontend';
     // proses data here
     if ('edit' == $method) {
         $data = stripslashes_deep($atts);
     }
     echo TF_Form::open(array('id' => 'tf_row_option_form'));
     echo sprintf('<input type="hidden" name="_state" value="%s">', $method);
     echo sprintf('<input type="hidden" name="_shortcode_name" value="%s">', $shortcode);
     echo sprintf('<input type="hidden" name="_template_id" value="%d">', $template_id);
     echo sprintf('<input type="hidden" name="sc_id" value="%s">', $shortcode_id);
     echo sprintf('<input type="hidden" name="_mode" value="%s">', $mode);
     echo TF_Form::render(TF_Shortcodes::row_fields(), $data);
     echo TF_Form::submit_button($label_submit_btn);
     echo TF_Form::close();
 }