/** * Display Toggle themify builder * wp admin bar */ function builder_admin_bar_menu($wp_admin_bar) { global $wp_query; $post_id = get_the_ID(); if (!Themify_Builder_Model::is_frontend_editor_page() || is_post_type_archive() && !is_post_type_archive('product') || !is_admin_bar_showing() || is_admin() || !current_user_can('edit_page', $post_id) || isset($wp_query->query_vars['product_cat']) || is_tax('product_tag')) { return; } $args = array(array('id' => 'themify_builder', 'title' => sprintf('<span class="themify_builder_front_icon"></span> %s', __('Themify Builder', 'themify')), 'href' => '#'), array('id' => 'toggle_themify_builder', 'parent' => 'themify_builder', 'title' => __('Turn On Builder', 'themify'), 'href' => '#', 'meta' => array('class' => 'toggle_tf_builder')), array('id' => 'duplicate_themify_builder', 'parent' => 'themify_builder', 'title' => __('Duplicate This Page', 'themify'), 'href' => '#', 'meta' => array('class' => 'themify_builder_dup_link'))); $help_args = array(array('id' => 'help_themify_builder', 'parent' => 'themify_builder', 'title' => __('Help', 'themify'), 'href' => 'http://themify.me/docs/builder', 'meta' => array('target' => '_blank', 'class' => ''))); if (is_singular() || is_page()) { $import_args = array(array('id' => 'import_themify_builder', 'parent' => 'themify_builder', 'title' => __('Import From', 'themify'), 'href' => '#'), array('id' => 'from_existing_pages_themify_builder', 'parent' => 'import_themify_builder', 'title' => __('Existing Pages', 'themify'), 'href' => '#', 'meta' => array('class' => 'themify_builder_import_page')), array('id' => 'from_existing_posts_themify_builder', 'parent' => 'import_themify_builder', 'title' => __('Existing Posts', 'themify'), 'href' => '#', 'meta' => array('class' => 'themify_builder_import_post')), array('id' => 'import_export_themify_builder', 'parent' => 'themify_builder', 'title' => __('Import / Export', 'themify'), 'href' => '#'), array('id' => 'import_file_themify_builder', 'parent' => 'import_export_themify_builder', 'title' => __('Import', 'themify'), 'href' => '#', 'meta' => array('class' => 'themify_builder_import_file')), array('id' => 'export_file_themify_builder', 'parent' => 'import_export_themify_builder', 'title' => __('Export', 'themify'), 'href' => wp_nonce_url('?themify_builder_export_file=true&postid=' . $post_id, 'themify_builder_export_nonce'), 'meta' => array('class' => 'themify_builder_export_file')), array('id' => 'layout_themify_builder', 'parent' => 'themify_builder', 'title' => __('Layouts', 'themify'), 'href' => '#'), array('id' => 'load_layout_themify_builder', 'parent' => 'layout_themify_builder', 'title' => __('Load Layout', 'themify'), 'href' => '#', 'meta' => array('class' => 'themify_builder_load_layout')), array('id' => 'save_layout_themify_builder', 'parent' => 'layout_themify_builder', 'title' => __('Save as Layout', 'themify'), 'href' => '#', 'meta' => array('class' => 'themify_builder_save_layout'))); global $Themify_Builder_Layouts; if (!is_singular($Themify_Builder_Layouts->post_types) || !Themify_Builder_Model::is_prebuilt_layout($post_id)) { $args = array_merge($args, $import_args); } else { unset($args[1]); // unset Turn on Builder Link } } $args = array_merge($args, $help_args); foreach ($args as $arg) { $wp_admin_bar->add_node($arg); } }