/** * Add Template menu to Admin Bar. * * @since 1.0.0 * @access public * @param object $wp_admin_bar */ public function add_admin_bar_menu($wp_admin_bar) { if (!TF_Model::is_tf_editor_active()) { return; } $args = array(array('id' => 'tf_template_admin_menu', 'title' => __('TF Template', 'themify-flow'), 'href' => '#'), array('id' => 'tf_template_admin_menu_options', 'parent' => 'tf_template_admin_menu', 'title' => __('Template Options', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_template_admin_menu_options')), array('id' => 'tf_template_admin_menu_global_styling', 'parent' => 'tf_template_admin_menu', 'title' => __('Global Styling', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_load_global_styling')), array('id' => 'tf_template_admin_menu_export', 'parent' => 'tf_template_admin_menu', 'title' => __('Export', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_template_admin_menu_export')), array('id' => 'tf_template_admin_menu_import', 'parent' => 'tf_template_admin_menu', 'title' => __('Replace (Import)', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_template_admin_menu_import'))); if (TF_Model::is_tf_styling_active()) { unset($args[1]); unset($args[3]); unset($args[4]); } else { if (!is_singular($this->post_type)) { $args = array(); } } foreach ($args as $arg) { $wp_admin_bar->add_node($arg); } }
/** * Register frontend menu. * * @since 1.0.0 * @access public * @param array $menus */ public function register_menu($menus) { $content_menus = array(); if (is_singular() && !is_singular(array('tf_template', 'tf_template_part')) && TF_Model::is_tf_editor_active() && !TF_Model::is_tf_styling_active()) { $content_menus['content_builder_view'] = array('label' => __('View the post/page', 'themify-flow'), 'href' => get_permalink()); $content_menus['content_builder_import'] = array('label' => __('Import Content', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_content_builder_import')); $content_menus['content_builder_export'] = array('label' => __('Export Content', 'themify-flow'), 'href' => wp_nonce_url(admin_url('post.php?post=' . get_the_ID() . '&action=export_tf_content_builder'), 'export_tf_nonce')); $menus = $content_menus; } else { if (is_singular() && !is_singular(array('tf_template', 'tf_template_part'))) { $content_menus['content_builder_list'] = array('label' => __('Content Builder', 'themify-flow'), 'href' => esc_url(add_query_arg('tf', 1, get_permalink()))); $menus = array_merge($content_menus, $menus); } } return $menus; }
/** * Use custom template for Template Part post type. * * @since 1.0.0 * @access public * @param string $original_template * @return string */ public function render_template_part_region($original_template) { if (is_singular(array($this->post_type))) { global $TF; if (isset($_GET['iframe']) && $_GET['iframe'] == true) { // remove admin bar inside iframe add_filter('show_admin_bar', '__return_false'); } $templatefilename = TF_Model::is_tf_editor_active() ? 'template-part-edit.php' : 'template-part.php'; // locate on theme $return_template = locate_template(array(trailingslashit('templates') . $templatefilename)); // Get default template if (!$return_template) { $return_template = $TF->framework_path() . '/includes/templates/' . $templatefilename; } return $return_template; } else { return $original_template; } }
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 } } }
/** * Filter shortcode atts params * * @since 1.0.0 * @access public * @param array $out * @param array $pairs * @param array $atts * @return array */ public function shortcode_atts_render_frontend($out) { global $TF; if (!isset($out['sc_id'])) { $out['sc_id'] = TF_Model::generate_block_id(); } if (!TF_Model::is_tf_styling_active() && TF_Model::is_tf_editor_active() && !$TF->in_template_part && !$TF->in_archive_loop) { $out['editable_markup'] = 'true'; } return $out; }
public function frontend_menu() { if (!is_user_logged_in() || !current_user_can('manage_options')) { return; } if (isset($_GET['iframe']) && $_GET['iframe'] == true) { return; } global $TF, $TF_Layout; $menus_list = array('edit_template' => array('label' => __('Edit Template', 'themify-flow'), 'href' => esc_url(add_query_arg('tf', 1, get_permalink(get_the_ID())))), 'import_export_template' => array('label' => __('Import/Export', 'themify-flow'), 'href' => '#'), 'import_template' => array('label' => __('Import', 'themify-flow'), 'href' => '#', 'parent' => 'import_export_template', 'meta' => array('class' => 'tf_import_template')), 'export_template' => array('label' => __('Export', 'themify-flow'), 'href' => wp_nonce_url(admin_url('post.php?post=' . get_the_ID() . '&action=export_tf_template'), 'export_tf_nonce'), 'parent' => 'import_export_template', 'meta' => array('class' => 'tf_template_admin_menu_export')), 'template_option' => array('label' => __('Template Options', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_template_admin_menu_options'))); $menus = array(); if (is_singular('tf_template') && !TF_Model::is_tf_editor_active()) { $menus['edit_template'] = $menus_list['edit_template']; } else { if (is_singular('tf_template') && TF_Model::is_tf_editor_active()) { $menus['import_export_template'] = $menus_list['import_export_template']; $menus['import_template'] = $menus_list['import_template']; $menus['export_template'] = $menus_list['export_template']; $menus['template_option'] = $menus_list['template_option']; } else { if (is_singular('tf_template_part') && !TF_Model::is_tf_editor_active()) { $menus['edit_template_part'] = array('label' => __('Edit Template Part', 'themify-flow'), 'href' => esc_url(add_query_arg('tf', 1, get_permalink(get_the_ID())))); } else { if (is_singular('tf_template_part') && TF_Model::is_tf_editor_active()) { $menus['import_export_template_part'] = array('label' => __('Import/Export', 'themify-flow'), 'href' => '#'); $menus['import_template_part'] = array('label' => __('Import', 'themify-flow'), 'href' => '#', 'parent' => 'import_export_template_part', 'meta' => array('class' => 'tf_import_template_part')); $menus['export_template_part'] = array('label' => __('Export', 'themify-flow'), 'href' => wp_nonce_url(admin_url('post.php?post=' . get_the_ID() . '&action=export_tf_template_part'), 'export_tf_nonce'), 'parent' => 'import_export_template_part'); } else { // In use template if (0 !== $TF_Layout->layout_id) { $menus['in_use_template'] = array('label' => __('Edit In-use Template', 'themify-flow'), 'href' => esc_url(add_query_arg(array('tf' => 1, 'tf_source_uri' => TF_Model::get_current_browser_url()), get_permalink($TF_Layout->layout_id)))); } // Template $menus['template_list'] = array('label' => __('Templates', 'themify-flow'), 'href' => '#'); $menus['template_list_add_new'] = array('label' => __('Add New', 'themify-flow'), 'href' => admin_url('edit.php?post_type=tf_template#tf_add_new'), 'parent' => 'template_list'); $menus['template_list_view'] = array('label' => __('View all Templates', 'themify-flow'), 'href' => admin_url('edit.php?post_type=tf_template'), 'parent' => 'template_list'); // Template Part $menus['template_part_list'] = array('label' => __('Template Parts', 'themify-flow'), 'href' => '#'); $menus['template_part_list_add_new'] = array('label' => __('Add New', 'themify-flow'), 'href' => admin_url('edit.php?post_type=tf_template_part#tf_add_new'), 'parent' => 'template_part_list'); $menus['template_part_list_view'] = array('label' => __('View all Template Parts', 'themify-flow'), 'href' => admin_url('edit.php?post_type=tf_template_part'), 'parent' => 'template_part_list'); if (TF_Model::is_tf_styling_active()) { $menus['global_styling'] = array('label' => __('Global Styling', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_load_global_styling')); $menus['custom_css'] = array('label' => __('Custom CSS', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_load_customcss')); } else { $menus['edit_global_styling'] = array('label' => __('Global Styling', 'themify-flow'), 'href' => esc_url(add_query_arg(array('tf' => 1, 'tf_global_styling' => 1)))); $menus['edit_custom_css'] = array('label' => __('Custom CSS', 'themify-flow'), 'href' => esc_url(add_query_arg(array('tf' => 1, 'tf_custom_css' => 1)))); } $menus['theme_settings'] = array('label' => __('Settings', 'themify-flow'), 'href' => admin_url('admin.php?page=tf-settings')); } } } } $menus = apply_filters('tf_frontend_menus', $menus); $frontend_menus = tf_parse_menu($menus); include_once sprintf('%s/includes/templates/template-frontend-menu.php', $TF->framework_path()); }