コード例 #1
1
ファイル: taxonomy.php プロジェクト: ahmedelhadi/TestProject
 /**
  * Add default value for 'taxonomy' field
  *
  * @param $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $default_args = array('hide_empty' => false);
     // Set default args
     $field['options']['args'] = !isset($field['options']['args']) ? $default_args : wp_parse_args($field['options']['args'], $default_args);
     $tax = get_taxonomy($field['options']['taxonomy']);
     $field['placeholder'] = empty($field['placeholder']) ? sprintf(__('Select a %s', 'framework'), $tax->labels->singular_name) : $field['placeholder'];
     switch ($field['options']['type']) {
         case 'select_advanced':
             $field = RWMB_Select_Advanced_Field::normalize_field($field);
             break;
         case 'checkbox_list':
         case 'checkbox_tree':
             $field = RWMB_Checkbox_List_Field::normalize_field($field);
             break;
         case 'select':
         case 'select_tree':
             $field = RWMB_Select_Field::normalize_field($field);
             break;
         default:
             $field['options']['type'] = 'select';
             $field = RWMB_Select_Field::normalize_field($field);
     }
     if (in_array($field['options']['type'], array('checkbox_tree', 'select_tree'))) {
         if (isset($field['options']['args']['parent'])) {
             $field['options']['parent'] = $field['options']['args']['parent'];
             unset($field['options']['args']['parent']);
         } else {
             $field['options']['parent'] = 0;
         }
     }
     $field['field_name'] = "{$field['id']}[]";
     return $field;
 }
コード例 #2
0
function scoper_force_custom_taxonomy_filters($post_id, $post)
{
    $post_type_obj = get_post_type_object($post->post_type);
    foreach ($post_type_obj->taxonomies as $taxonomy) {
        // if terms were selected, WP core already applied the filter and there is no need to apply default terms
        if (in_array($taxonomy, array('category', 'post_tag')) || did_action("pre_post_{$taxonomy}")) {
            continue;
        }
        // don't filter term selection for non-hierarchical taxonomies
        if (empty($GLOBALS['wp_taxonomies'][$taxonomy]->hierarchical)) {
            continue;
        }
        if ($taxonomy_obj = get_taxonomy($taxonomy)) {
            if (!empty($_POST['tax_input'][$taxonomy]) && is_array($_POST['tax_input'][$taxonomy]) && (reset($_POST['tax_input'][$taxonomy]) || count($_POST['tax_input'][$taxonomy]) > 1)) {
                // complication because (as of 3.0) WP always includes a zero-valued first array element
                $tags = $_POST['tax_input'][$taxonomy];
            } elseif ('auto-draft' != $post->post_status) {
                $tags = (array) get_option("default_{$taxonomy}");
            } else {
                $tags = array();
            }
            if ($tags) {
                if (!empty($_POST['tax_input']) && is_array($_POST['tax_input'][$taxonomy])) {
                    // array = hierarchical, string = non-hierarchical.
                    $tags = array_filter($tags);
                }
                if (current_user_can($taxonomy_obj->cap->assign_terms)) {
                    $tags = apply_filters("pre_post_{$taxonomy}", $tags);
                    $tags = apply_filters("{$taxonomy}_pre", $tags);
                    wp_set_post_terms($post_id, $tags, $taxonomy);
                }
            }
        }
    }
}
コード例 #3
0
ファイル: widgets.php プロジェクト: aarongillett/B22-151217
 /**
  * This function creates and prints the widget's HTML for the front-end.
  *
  * As of 1.1, you are allowed to select whether you want the
  * term to link to the archive page or the actual post.
  * 
  * @since 1.0
  * @uses $cpt_onomies_manager, $cpt_onomy
  * @param array $args - arguments to customize the widget
  * @param array $instance - the widget's saved information
  */
 function widget($args, $instance)
 {
     global $cpt_onomies_manager, $cpt_onomy;
     extract($args);
     if (isset($instance['taxonomy'])) {
         $current_taxonomy = $instance['taxonomy'];
         if ($cpt_onomies_manager->is_registered_cpt_onomy($current_taxonomy)) {
             // get tag cloud
             $tag_cloud = $cpt_onomy->wp_tag_cloud(apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy, 'echo' => false, 'link' => isset($instance['term_link']) && $instance['term_link'] == 'cpt_post' ? 'cpt_post' : 'view')));
             // if empty, and they dont' want to show if empty, then don't show
             if ($instance['show_if_empty'] || !$instance['show_if_empty'] && !empty($tag_cloud)) {
                 if (!empty($instance['title'])) {
                     $title = $instance['title'];
                 } else {
                     $tax = get_taxonomy($current_taxonomy);
                     $title = $tax->labels->name;
                 }
                 $title = apply_filters('widget_title', $title, $instance, $this->id_base);
                 echo $before_widget;
                 if ($title) {
                     echo $before_title . __($title, CPT_ONOMIES_TEXTDOMAIN) . $after_title;
                 }
                 echo '<div class="tagcloud">' . $tag_cloud . "</div>\n";
                 echo $after_widget;
             }
         }
     }
 }
コード例 #4
0
ファイル: filter.class.php プロジェクト: nengineer/WP-Anatomy
 public function get_markup()
 {
     $walker = new WCMF_walker();
     foreach ($this->taxonomies as $tax) {
         wp_dropdown_categories(array('taxonomy' => $tax, 'hide_if_empty' => true, 'show_option_all' => sprintf(get_taxonomy($tax)->labels->all_items), 'hide_empty' => true, 'hierarchical' => is_taxonomy_hierarchical($tax), 'show_count' => true, 'orderby' => 'name', 'selected' => '0' !== get_query_var($tax) ? get_query_var($tax) : false, 'name' => $tax, 'id' => $tax, 'walker' => $walker));
     }
 }
コード例 #5
0
ファイル: qqp_ctax.php プロジェクト: srolland/dev
 function build_taxo_dd_filter()
 {
     $tax_name = $this->name;
     $tax_obj = get_taxonomy($tax_name);
     $selected = empty($_GET[$tax_name]) ? '' : $_GET[$tax_name];
     wp_dropdown_categories(array('show_option_all' => __('Show All ' . $tax_obj->label . '&nbsp;'), 'taxonomy' => $tax_name, 'name' => $tax_obj->name, 'orderby' => 'name', 'selected' => $selected, 'hierarchical' => $tax_obj->hierarchical, 'show_count' => false, 'hide_empty' => false));
 }
コード例 #6
0
 public function test_unregister()
 {
     $tag = new Attachment_Tag();
     $tag->unregister();
     $tax = get_taxonomy('attachment_tag');
     $this->assertFalse($tax);
 }
コード例 #7
0
 public function add_taxonomy($taxonomy)
 {
     if (!array_search($taxonomy, $this->get_taxonomies())) {
         $this->taxonomies[] = $taxonomy;
         $this->add_taxonomy_object(get_taxonomy($taxonomy));
     }
 }
コード例 #8
0
ファイル: tags.php プロジェクト: vanie3/appland
 public function postStoreProcess($table, $newTags = array(), $replace = true)
 {
     return false;
     if (!empty($table->newTags) && empty($newTags)) {
         $newTags = $table->newTags;
     }
     // If existing row, check to see if tags have changed.
     $newTable = clone $table;
     $newTable->reset();
     $key = $newTable->getKeyName();
     $typeAlias = $this->typeAlias;
     $result = false;
     if ($this->tagsChanged || !empty($newTags) && $newTags[0] != '') {
         $taxonomy_obj = get_taxonomy($typeAlias);
         if (is_array($newTags)) {
             // array = hierarchical, string = non-hierarchical.
             $newTags = array_filter($newTags);
         }
         if (current_user_can($taxonomy_obj->cap->assign_terms)) {
             $result = wp_set_post_terms($table->id, $newTags, $typeAlias);
             if (is_array($result) && count($result) > 0) {
                 $result = true;
             } elseif (is_object($result)) {
                 $result = false;
             }
         }
     }
     return $result;
 }
コード例 #9
0
 static function add_attachment_fields_to_edit($form_fields, $post)
 {
     $terms = get_object_term_cache($post->ID, self::TAXONOMY);
     $field = array();
     $taxonomy_obj = (array) get_taxonomy(self::TAXONOMY);
     if (!$taxonomy_obj['public'] || !$taxonomy_obj['show_ui']) {
         continue;
     }
     if (false === $terms) {
         $terms = wp_get_object_terms($post->ID, self::TAXONOMY);
     }
     $values = wp_list_pluck($terms, 'term_id');
     ob_start();
     wp_terms_checklist($post->ID, array('taxonomy' => self::TAXONOMY, 'checked_ontop' => false, 'walker' => new Walker_WP_Media_Taxonomy_Checklist($post->ID)));
     $output = ob_get_clean();
     if (!empty($output)) {
         $output = '<ul class="term-list">' . $output . '</ul>';
         $output .= wp_nonce_field('save_attachment_media_categories', 'media_category_nonce', false, false);
     } else {
         $output = '<ul class="term-list"><li>No ' . $taxonomy_obj['label'] . '</li></ul>';
     }
     $field = array('label' => !empty($taxonomy_obj['label']) ? $taxonomy_obj['label'] : self::TAXONOMY, 'value' => join(', ', $values), 'show_in_edit' => false, 'input' => 'html', 'html' => $output);
     $form_fields[self::TAXONOMY] = $field;
     return $form_fields;
 }
コード例 #10
0
	static function handler() {
		$defaults = array(
			'taxonomy' => 'post_tag',
			'delete_tags' => false,
			'action' => false,
			'action2' => false
		);

		$data = shortcode_atts( $defaults, $_REQUEST );

		$tax = get_taxonomy( $data['taxonomy'] );
		if ( !$tax )
			return;

		if ( !current_user_can( $tax->cap->manage_terms ) )
			return;

		add_action( 'admin_enqueue_scripts', array( __CLASS__, 'script' ) );
		add_action( 'admin_footer', array( __CLASS__, 'inputs' ) );

		$action = false;
		foreach ( array( 'action', 'action2' ) as $key ) {
			if ( $data[ $key ] && '-1' != $data[ $key ] ) {
				$action = $data[ $key ];
			}
		}

		if ( !$action )
			return;

		self::delegate_handling( $action, $data['taxonomy'], $data['delete_tags'] );
	}
コード例 #11
0
ファイル: Taxonomy.php プロジェクト: aaemnnosttv/silk
 /**
  * Create a new instance from an existing taxonomy.
  *
  * @param  string $id The taxonomy identifier
  *
  * @throws NonExistentTaxonomyException
  *
  * @return static
  */
 public static function load($id)
 {
     if (!($object = get_taxonomy($id))) {
         throw new NonExistentTaxonomyException("No taxonomy exists with name '{$id}'.");
     }
     return new static($object);
 }
コード例 #12
0
 /**
  * Initialization function, similar to __construct()
  *
  * @since 0.1
  */
 public static function initialize()
 {
     self::$wp_4dot0_plus = version_compare(get_bloginfo('version'), '4.0', '>=');
     /*
      * Set up the Media/Assistant submenu table column definitions
      */
     $taxonomies = get_taxonomies(array('show_ui' => true), 'names');
     foreach ($taxonomies as $tax_name) {
         if (MLACore::mla_taxonomy_support($tax_name)) {
             $tax_object = get_taxonomy($tax_name);
             self::$default_columns['t_' . $tax_name] = esc_html($tax_object->labels->name);
             self::$default_hidden_columns[] = 't_' . $tax_name;
             // self::$default_sortable_columns [] = none at this time
         }
         // supported taxonomy
     }
     // foreach $tax_name
     /*
      * For WP 4.3+ icon will be merged with the first visible preferred column
      */
     if (MLATest::$wp_4dot3_plus) {
         unset(self::$default_columns['icon']);
     }
     self::$default_columns = array_merge(self::$default_columns, MLACore::mla_custom_field_support('default_columns'));
     self::$default_hidden_columns = array_merge(self::$default_hidden_columns, MLACore::mla_custom_field_support('default_hidden_columns'));
     self::$default_sortable_columns = array_merge(self::$default_sortable_columns, MLACore::mla_custom_field_support('default_sortable_columns'));
 }
コード例 #13
0
ファイル: test-class-modules.php プロジェクト: pra85/sensei
 /**
  * Testing Sensei_Core_Modules::get_term_author
  */
 public function testGetTermAuthor()
 {
     // setup assertions
     $test_user_id = wp_create_user('teacherGetTermAuthor', 'teacherGetTermAuthor', '*****@*****.**');
     //insert a general term
     wp_insert_term('Get Started', 'module');
     //insert a term as if from the user
     wp_insert_term('Get Started Today', 'module', array('description' => 'A yummy apple.', 'slug' => $test_user_id . '-get-started-today'));
     // does the function exist?
     $this->assertTrue(method_exists('Sensei_Core_Modules', 'get_term_authors'), 'The function Sensei_Core_Modules::get_term_author does not exist ');
     // does the taxonomy exist
     $module_taxonomy = get_taxonomy('module');
     $this->assertTrue($module_taxonomy->public, 'The module taxonomy is not loaded');
     // does it return empty array id for bogus term nam?
     $term_authors = Sensei_Core_Modules::get_term_authors('bogusnonexistan');
     $this->assertTrue(empty($term_authors), 'The function should return false for an invalid term');
     //does it return the admin user for a valid term ?
     $admin = get_user_by('email', get_bloginfo('admin_email'));
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started');
     $this->assertTrue($admin == $term_authors[0], 'The function should return admin user for normal module term.');
     // does it return the expected new user for the given term registered with that id in front of the slug?
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started Today');
     $this->assertTrue(get_userdata($test_user_id) == $term_authors[0], 'The function should admin user for normal module term.');
     // what about terms with the same name but different slug?
     // It should return 2 authors as we've created 2 with the same name
     // insert a term that is the same as the first one
     wp_insert_term('Get Started', 'module', array('description' => 'A yummy apple.', 'slug' => $test_user_id . '-get-started'));
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started');
     $this->assertTrue(2 == count($term_authors), 'The function should admin user for normal module term.');
 }
コード例 #14
0
function sandwich_tag_cloud_widget_shortcode($attr, $content)
{
    $default = '';
    foreach (get_taxonomies() as $taxonomy) {
        $tax = get_taxonomy($taxonomy);
        if (!$tax->show_tagcloud || empty($tax->labels->name)) {
            continue;
        }
        $default = esc_attr($taxonomy);
        break;
    }
    $attr = wp_parse_args($attr, array('title' => __('Tag Cloud', 'pbsandwich'), 'taxonomy' => $default, 'hide_title' => false));
    $hideTitleClass = '';
    if ($attr['hide_title']) {
        $hideTitleClass = 'hide_title';
    }
    ob_start();
    ?>
	<div class="sandwich <?php 
    echo $hideTitleClass;
    ?>
">
		<?php 
    the_widget('WP_Widget_Tag_Cloud', $attr);
    ?>
	</div>
	
	<?php 
    return ob_get_clean();
}
コード例 #15
0
 /**
  * Migrate meta values to taxonomy terms. Delete meta after import
  *
  * ## OPTIONS
  *
  * <meta-key>
  * : Meta key to convert
  *
  * <taxonomy-slug>
  * : Taxonomy to move values into
  *
  * [--<field>=<value>]
  * : One or more args to pass to WP_Query.
  *
  * ## EXAMPLES
  *
  *     wp mtt migrate meta_key taxonomy_slug
  *     wp mtt migrate meta_key taxonomy_slug --posts_per_page=200 --paged=2
  *
  */
 function migrate($args, $assoc_args)
 {
     list($meta_key, $taxonomy) = $args;
     if (!($taxonomy_object = get_taxonomy($taxonomy))) {
         WP_CLI::error(sprintf("The taxonomy '%s' doesn't exist", $taxonomy));
     }
     $defaults = array('post_type' => $taxonomy_object->object_type, 'posts_per_page' => -1, 'post_status' => 'any');
     $query_args = array_merge($defaults, $assoc_args);
     $query = new WP_Query($query_args);
     // summary
     WP_CLI::log(sprintf("---\nPer page: %d \nPage: %d \nTotal pages: %d\n---", $query_args['posts_per_page'], isset($query_args['paged']) ? $query_args['paged'] : 1, $query->max_num_pages));
     while ($query->have_posts()) {
         $query->the_post();
         $id = get_the_id();
         // get meta
         $metas = get_post_meta($id, $meta_key);
         // create term
         if (!$metas) {
             WP_CLI::log(WP_CLI::colorize("%c[{$id}]%n No meta, skipped"));
         } else {
             if (!is_wp_error(wp_set_object_terms($id, $metas, $taxonomy, true))) {
                 WP_CLI::log(WP_CLI::colorize("%g[{$id}]%n Migrated: " . implode(', ', $metas)));
                 // clean meta
                 delete_post_meta($id, $meta_key);
             } else {
                 WP_CLI::log(WP_CLI::colorize("%r[{$id}]%n Error: Could not set terms for post"));
             }
         }
     }
 }
コード例 #16
0
function scoper_admin_terms_js()
{
    if (!empty($_REQUEST['action']) && 'edit' == $_REQUEST['action']) {
        return;
    }
    if (!empty($_REQUEST['taxonomy'])) {
        // using this with edit-link-categories
        if ($tx_obj = get_taxonomy($_REQUEST['taxonomy'])) {
            $cap_name = $tx_obj->cap->manage_terms;
        }
    }
    if (empty($cap_name)) {
        $cap_name = 'manage_categories';
    }
    if (cr_user_can($cap_name, BLOG_SCOPE_RS)) {
        return;
    }
    ?>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready( function($) {
	$('#parent option[value="-1"]').remove();
});
/* ]]> */
</script>
<?php 
}
コード例 #17
0
ファイル: taxonomy.php プロジェクト: wp-papi/papi
/**
 * Get taxonomy label.
 *
 * @param  string $taxonomy
 * @param  string $label
 * @param  string $default
 *
 * @return string
 */
function papi_get_taxonomy_label($taxonomy, $label, $default = '')
{
    if (!taxonomy_exists($taxonomy)) {
        return $default;
    }
    return get_taxonomy($taxonomy)->labels->{$label};
}
コード例 #18
0
ファイル: Term.php プロジェクト: felixarntz/wp-objects
 public function get_taxonomy($output = 'name')
 {
     if ('object' === $output) {
         return get_taxonomy($this->item->taxonomy);
     }
     return $this->item->taxonomy;
 }
コード例 #19
0
function _act_get_body_data()
{
    global $post;
    $body_data = array();
    //  echo 'pid';
    //
    $post_type = get_post_type(get_the_ID());
    if (is_archive()) {
        $post_type = "archive";
    }
    if (is_front_page()) {
        $post_type = 'home';
    }
    $body_data['post-type'] = $post_type;
    $post_slug = $post->post_name;
    if (is_archive() and isset(get_queried_object()->taxonomy)) {
        $tax = get_taxonomy(get_queried_object()->taxonomy);
        $post_slug = sanitize_title($tax->labels->singular_name);
    } elseif (is_archive() and !isset(get_queried_object()->taxonomy)) {
        $post_slug = get_queried_object()->name;
    }
    if (is_home()) {
        $post_slug = 'blog';
    }
    if (is_home() && is_paged()) {
        $post_slug = 'blog_paged';
    }
    $body_data['post-slug'] = $post_slug;
    return $body_data;
}
コード例 #20
0
 public function init()
 {
     global $sitepress;
     $tax_get = filter_input(INPUT_GET, 'taxonomy');
     require ICL_PLUGIN_PATH . '/menu/term-taxonomy-menus/wpml-term-language-filter.class.php';
     if (($trid = filter_input(INPUT_GET, 'trid')) && ($source_lang = filter_input(INPUT_GET, 'source_lang')) && get_taxonomy($tax_get) !== false) {
         $translations = $sitepress->get_element_translations($trid, 'tax_' . $this->taxonomy);
         if (isset($translations[$_GET['lang']]) && !empty($translations[$_GET['lang']]->term_id)) {
             wp_redirect(get_edit_term_link($translations[$_GET['lang']]->term_id, $tax_get));
             exit;
         } else {
             add_action('admin_notices', array($this, '_tax_adding'));
         }
     }
     $term_lang_filter = new WPML_Term_Language_Filter(icl_get_setting('default_language'));
     if ($this->taxonomy === 'category') {
         add_action('edit_category_form', array($this, 'wpml_edit_term_form'));
     } else {
         add_action('add_tag_form', array($this, 'wpml_edit_term_form'));
         add_action('edit_tag_form', array($this, 'wpml_edit_term_form'));
     }
     add_action('admin_print_scripts-edit-tags.php', array($this, 'js_scripts_tags'));
     add_filter('wp_dropdown_cats', array($this, 'wp_dropdown_cats_select_parent'), 10, 2);
     add_action('admin_footer', array($term_lang_filter, 'terms_language_filter'));
 }
コード例 #21
0
ファイル: functions.php プロジェクト: k111/wp_theme_skeleton
function mypace_custom_navi_menu($classes, $item)
{
    global $wp_query;
    $singular_slug = 'service';
    $page_for_custom_type_title = 'サービス';
    $page_for_posts = get_option('page_for_posts');
    $post_type_query = $wp_query->query_vars['post_type'];
    $del_flag = true;
    $add_flag = false;
    if (is_singular('post') || is_category() || is_tag()) {
        $del_flag = false;
    } elseif (is_author() || is_date() || is_author()) {
        if (in_array($post_type_query, array('', 'post'))) {
            $del_flag = false;
        } elseif ($post_type_query == $custom_post_type) {
            $add_flag = true;
        }
    } elseif (is_tax()) {
        $taxonomy = get_taxonomy($wp_query->query_vars['taxonomy']);
        if (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == 'post') {
            $del_flag = false;
        } elseif (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == $singular_slug) {
            $add_flag = true;
        }
    } elseif (is_singular($singular_slug)) {
        $add_flag = true;
    }
    if ($del_flag && is_numeric($page_for_posts) && $item->object_id == $page_for_posts && $item->object == 'page' && ($key = array_search('current_page_parent', $classes))) {
        unset($classes[$key]);
    } elseif ($add_flag && $item->title == $page_for_custom_type_title && $item->object == 'page') {
        $classes[] = 'current_page_parent';
    }
    return $classes;
}
コード例 #22
0
ファイル: class-mla-ajax.php プロジェクト: jonpetersen/PHTC
 /**
  * Add flat taxonomy term from "checklist" meta box on the Media Manager Modal Window
  *
  * Adapted from the WordPress post_categories_meta_box() in /wp-admin/includes/meta-boxes.php.
  *
  * @since 2.20
  *
  * @param string The taxonomy name, from $_POST['action']
  *
  * @return void Sends JSON response with updated HTML for the checklist
  */
 private static function _mla_ajax_add_flat_term($key)
 {
     $taxonomy = get_taxonomy($key);
     check_ajax_referer($_POST['action'], '_ajax_nonce-add-' . $key, true);
     if (!current_user_can($taxonomy->cap->edit_terms)) {
         wp_die(-1);
     }
     $new_names = explode(',', $_POST['new' . $key]);
     $new_terms_markup = '';
     foreach ($new_names as $name) {
         if ('' === sanitize_title($name)) {
             continue;
         }
         if (!($id = term_exists($name, $key))) {
             $id = wp_insert_term($name, $key);
         }
         if (is_wp_error($id)) {
             continue;
         }
         if (is_array($id)) {
             $id = absint($id['term_id']);
         } else {
             continue;
         }
         $term = get_term($id, $key);
         $name = $term->name;
         $new_terms_markup .= "<li id='{$key}-{$id}'><label class='selectit'><input value='{$name}' type='checkbox' name='tax_input[{$key}][]' id='in-{$key}-{$id}' checked='checked' />{$name}</label></li>\n";
     }
     // foreach new_name
     $input_new_parent_name = "new{$key}_parent";
     $supplemental = "<input type='hidden' name='{$input_new_parent_name}' id='{$input_new_parent_name}' value='-1' />";
     $add = array('what' => $key, 'id' => $id, 'data' => $new_terms_markup, 'position' => -1, 'supplemental' => array('newcat_parent' => $supplemental));
     $x = new WP_Ajax_Response($add);
     $x->send();
 }
コード例 #23
0
ファイル: config.php プロジェクト: quyip8818/wps
function kleo_sensei_title($args)
{
    $title = false;
    global $post, $wp_query;
    if (is_tax('course-category')) {
        $taxonomy_obj = $wp_query->get_queried_object();
        $taxonomy_short_name = $taxonomy_obj->taxonomy;
        $taxonomy_raw_obj = get_taxonomy($taxonomy_short_name);
        $title = sprintf(__('%1$s Archives: %2$s', 'woothemes-sensei'), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name);
    }
    if (is_singular('sensei_message')) {
        $content_post_id = get_post_meta($post->ID, '_post', true);
        if ($content_post_id) {
            $title = sprintf(__('Re: %1$s', 'woothemes-sensei'), '<a href="' . get_permalink($content_post_id) . '">' . get_the_title($content_post_id) . '</a>');
        }
    }
    if (is_singular('course')) {
        remove_all_actions('sensei_course_image');
        remove_all_actions('sensei_course_single_title');
    }
    if (is_singular('lesson')) {
        remove_all_actions('sensei_lesson_image');
        remove_all_actions('sensei_lesson_single_title');
    }
    if ($title) {
        $breadcrumb_data = kleo_breadcrumb(array('show_title' => false, 'show_browse' => false, 'separator' => ' ', 'show_home' => __('Home', 'kleo_framework'), 'echo' => false));
        $breadcrumb_data = str_replace('</div>', '<span class="sep"> </span> <span class="active">' . $title . '</span> </div>', $breadcrumb_data);
        $args['output'] = str_replace('{breadcrumb_data}', $breadcrumb_data, $args['output']);
        $args['title'] = $title;
    }
    return $args;
}
コード例 #24
0
function wds_autolinks_settings()
{
    $name = 'wds_autolinks';
    $title = __('Automatic Links', 'wds');
    $description = __('<p>Sometimes you want to always link certain key words to a page on your blog or even a whole new site all together.</p>
	<p>For example, maybe anytime you write the words \'WordPress news\' you want to automatically create a link to the WordPress news blog, wpmu.org. Without this plugin, you would have to manually create these links each time you write the text in your pages and posts - which can be no fun at all.</p>
	<p>This section lets you set those key words and links. First, choose if you want to automatically link key words in posts, pages, or any custom post types you might be using. Usually when you are using automatic links, you will want to check all of the options here.</p>', 'wds');
    $fields = array();
    foreach (get_post_types() as $post_type) {
        if (!in_array($post_type, array('revision', 'nav_menu_item', 'attachment'))) {
            $pt = get_post_type_object($post_type);
            $key = strtolower($pt->name);
            $post_types["l{$key}"] = $pt->labels->name;
            $insert["{$key}"] = $pt->labels->name;
        }
    }
    foreach (get_taxonomies() as $taxonomy) {
        if (!in_array($taxonomy, array('nav_menu', 'link_category', 'post_format'))) {
            $tax = get_taxonomy($taxonomy);
            $key = strtolower($tax->labels->name);
            $taxonomies["l{$key}"] = $tax->labels->name;
        }
    }
    $linkto = array_merge($post_types, $taxonomies);
    $insert['comment'] = __('Comments', 'wds');
    $fields['internal'] = array('title' => '', 'intro' => '', 'options' => array(array('type' => 'checkbox', 'name' => 'insert', 'title' => __('Insert links in', 'wds'), 'items' => $insert), array('type' => 'checkbox', 'name' => 'linkto', 'title' => __('Link to', 'wds'), 'items' => $linkto), array('type' => 'dropdown', 'name' => 'cpt_char_limit', 'title' => __('Minimum post title length', 'wds'), 'description' => __('This is the minimum number of characters your post title has to have to be considered for insertion as auto-link.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 25)), array_merge(array(__('Default', 'wds')), range(1, 25)))), array('type' => 'dropdown', 'name' => 'tax_char_limit', 'title' => __('Minimum taxonomy title length', 'wds'), 'description' => __('This is the minimum number of characters your taxonomy title has to have to be considered for insertion as auto-link.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 25)), array_merge(array(__('Default', 'wds')), range(1, 25)))), array('type' => 'checkbox', 'name' => 'allow_empty_tax', 'title' => __('Empty taxonomies', 'wds'), 'items' => array('allow_empty_tax' => __('Allow autolinks to empty taxonomies', 'wds'))), array('type' => 'checkbox', 'name' => 'excludeheading', 'title' => __('Exclude Headings', 'wds'), 'items' => array('excludeheading' => __('Prevent linking in heading tags', 'wds'))), array('type' => 'text', 'name' => 'ignorepost', 'title' => __('Ignore posts and pages', 'wds'), 'description' => __('Paste in the IDs, slugs or titles for the post/pages you wish to exclude and separate them by commas', 'wds')), array('type' => 'text', 'name' => 'ignore', 'title' => __('Ignore keywords', 'wds'), 'description' => __('Paste in the keywords you wish to exclude and separate them by commas', 'wds')), array('type' => 'dropdown', 'name' => 'link_limit', 'title' => __('Maximum autolinks number limit', 'wds'), 'description' => __('This is the maximum number of autolinks that will be added to your posts.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 20)), array_merge(array(__('Unlimited', 'wds')), range(1, 20)))), array('type' => 'dropdown', 'name' => 'single_link_limit', 'title' => __('Maximum single autolink occurrence', 'wds'), 'description' => __('This is a number of single link replacement occurrences.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 10)), array_merge(array(__('Unlimited', 'wds')), range(1, 10)))), array('type' => 'textarea', 'name' => 'customkey', 'title' => __('Custom Keywords', 'wds'), 'description' => __('Paste in the extra keywords you want to automaticaly link. Use comma to seperate keywords and add target url at the end. Use a new line for new url and set of keywords.
				<br />Example:<br />
				<code>WPMU DEV, plugins, themes, http://premium.wpmudev.org/<br />
				WordPress News, http://wpmu.org/<br /></code>', 'wds')), array('type' => 'checkbox', 'name' => 'reduceload', 'title' => __('Other settings', 'wds'), 'items' => array('onlysingle' => __('Process only single posts and pages', 'wds'), 'allowfeed' => __('Process RSS feeds', 'wds'), 'casesens' => __('Case sensitive matching', 'wds'), 'customkey_preventduplicatelink' => __('Prevent duplicate links', 'wds'), 'target_blank' => __('Open links in new tab/window', 'wds'), 'rel_nofollow' => __('Autolinks <code>nofollow</code>', 'wds')))));
    $contextual_help = '';
    if (wds_is_wizard_step('5')) {
        $settings = new WDS_Core_Admin_Tab($name, $title, $description, $fields, 'wds', $contextual_help);
    }
}
コード例 #25
0
function manage_portfolio_columns($column)
{
    global $post;
    if ($post->post_type == "portfolio") {
        switch ($column) {
            case "description":
                the_excerpt();
                break;
            case "portfolio_categories":
                $terms = get_the_terms($post->ID, 'portfolio_category');
                if (!empty($terms)) {
                    foreach ($terms as $t) {
                        $output[] = "<a href='edit.php?post_type=portfolio&portfolio_tag={$t->slug}'> " . esc_html(sanitize_term_field('name', $t->name, $t->term_id, 'portfolio_tag', 'display')) . "</a>";
                    }
                    $output = implode(', ', $output);
                } else {
                    $t = get_taxonomy('portfolio_category');
                    $output = "No {$t->label}";
                }
                echo $output;
                break;
            case 'thumbnail':
                echo the_post_thumbnail('thumbnail');
                break;
        }
    }
}
コード例 #26
0
 /**
  * Return the terms for the given type.
  *
  * @param int $site_id Blog ID.
  *
  * @return array
  */
 public function get_terms_for_site($site_id)
 {
     $out = [];
     switch_to_blog($site_id);
     $taxonomy_object = get_taxonomy($this->taxonomy_name);
     if (!current_user_can($taxonomy_object->cap->edit_terms)) {
         $terms = [];
     } else {
         $terms = get_terms($this->taxonomy_name, ['hide_empty' => FALSE]);
     }
     foreach ($terms as $term) {
         if (is_taxonomy_hierarchical($this->taxonomy_name)) {
             $ancestors = get_ancestors($term->term_id, $this->taxonomy_name);
             if (!empty($ancestors)) {
                 foreach ($ancestors as $ancestor) {
                     $parent_term = get_term($ancestor, $this->taxonomy_name);
                     $term->name = $parent_term->name . '/' . $term->name;
                 }
             }
         }
         $out[$term->term_taxonomy_id] = esc_html($term->name);
     }
     restore_current_blog();
     uasort($out, 'strcasecmp');
     return $out;
 }
コード例 #27
0
 /**
  * returns the language based on the queried content
  *
  * @since 1.2
  *
  * @return object|bool detected language, false if none was found
  */
 protected function get_language_from_content()
 {
     // no language set for 404
     if (is_404() || is_attachment() && !$this->options['media_support']) {
         return $this->get_preferred_language();
     }
     if ($var = get_query_var('lang')) {
         $lang = explode(',', $var);
         $lang = $this->model->get_language(reset($lang));
         // choose the first queried language
     } elseif ((is_single() || is_page() || is_attachment() && $this->options['media_support']) && (($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) || ($var = get_query_var('attachment_id')))) {
         $lang = $this->model->post->get_language($var);
     } else {
         foreach ($this->model->get_translated_taxonomies() as $taxonomy) {
             if ($var = get_query_var(get_taxonomy($taxonomy)->query_var)) {
                 $lang = $this->model->term->get_language($var, $taxonomy);
             }
         }
     }
     /**
      * Filter the language before it is set from the content
      *
      * @since 0.9
      *
      * @param bool|object $lang language object or false if none was found
      */
     return apply_filters('pll_get_current_language', isset($lang) ? $lang : false);
 }
コード例 #28
0
 /**
  * @param        $false
  * @param string $taxonomy
  *
  * @return array|bool
  */
 function get_label_translations($false, $taxonomy)
 {
     global $sitepress, $wpdb;
     $return = false;
     $taxonomy_object = get_taxonomy($taxonomy);
     // Careful index checking here, otherwise some of those private taxonomies used by WooCommerce will result in errors here.
     if ($taxonomy_object && isset($taxonomy_object->label) && isset($taxonomy_object->labels) && isset($taxonomy_object->labels->singular_name)) {
         $label = $taxonomy_object->label;
         $singular_label = $taxonomy_object->labels->singular_name;
         $str_lang = $sitepress->get_user_admin_language($sitepress->get_current_user()->ID);
         $corrections = 0;
         if ($str_lang != 'en') {
             $label_translations_sql = "\n\t\t\t\t\t\t\t\t\t\tSELECT s.value as original, t.value as translation\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_strings s\n\t\t\t\t\t\t\t\t\t\tJOIN {$wpdb->prefix}icl_string_translations t ON t.string_id = s.id\n\t\t\t\t\t\t\t\t\t\tAND s.name LIKE 'taxonomy%%name:%%'\n\t\t\t\t\t\t\t";
             $label_translations = $wpdb->get_results($label_translations_sql);
             foreach ($label_translations as $label_translation) {
                 if ($label_translation->translation == $singular_label) {
                     $singular_label = $label_translation->original;
                     $corrections++;
                 } elseif ($label_translation->translation == $label) {
                     $label = $label_translation->original;
                     $corrections++;
                 }
             }
         }
         $return = $this->build_label_array($singular_label, $label, $str_lang, $corrections);
     }
     $return['st_default_lang'] = 'en';
     return $return;
 }
コード例 #29
0
function TOPluginMenu()
{
    include TOPATH . '/include/interface.php';
    include TOPATH . '/include/terms_walker.php';
    include TOPATH . '/include/options.php';
    add_options_page('Taxonomy Terms Order', '<img class="menu_pto" src="' . TOURL . '/images/menu-icon.gif" alt="" />' . __('Taxonomy Terms Order', 'to'), 'manage_options', 'to-options', 'to_plugin_options');
    $options = get_option('tto_options');
    if (!isset($options['level'])) {
        $options['level'] = 8;
    }
    //put a menu within all custom types if apply
    $post_types = get_post_types();
    foreach ($post_types as $post_type) {
        //check if there are any taxonomy for this post type
        $post_type_taxonomies = get_object_taxonomies($post_type);
        foreach ($post_type_taxonomies as $key => $taxonomy_name) {
            $taxonomy_info = get_taxonomy($taxonomy_name);
            if ($taxonomy_info->hierarchical !== TRUE) {
                unset($post_type_taxonomies[$key]);
            }
        }
        if (count($post_type_taxonomies) == 0) {
            continue;
        }
        if ($post_type == 'post') {
            add_submenu_page('edit.php', __('Taxonomy Order', 'to'), __('Taxonomy Order', 'to'), 'level_' . $options['level'], 'to-interface-' . $post_type, 'TOPluginInterface');
        } else {
            add_submenu_page('edit.php?post_type=' . $post_type, __('Taxonomy Order', 'to'), __('Taxonomy Order', 'to'), 'level_' . $options['level'], 'to-interface-' . $post_type, 'TOPluginInterface');
        }
    }
}
コード例 #30
-1
ファイル: mu-plugin-faq-cpt.php プロジェクト: kmwalsh/KMW-FAQ
    function kmw__faq_sort_categories($taxtype)
    {
        $args = array('parent' => 0, 'orderby' => 'name', 'ord' => 'ASC', 'style' => 'list', 'hide_empty' => 0, 'title_li' => '', 'number' => null, 'taxonomy' => $taxtype);
        $get_tax_name = get_taxonomy($taxtype);
        $cats = get_categories($args);
        ob_start();
        ?>
			<div class="dropdown-sorter">
				<span class="button dropdown-button">
					<?php 
        echo $get_tax_name->label;
        ?>
					<ul>
					<?php 
        foreach ($cats as $category) {
            ?>
						<li><a href="<?php 
            echo get_term_link($category);
            ?>
"><?php 
            echo $category->name;
            ?>
</a></li>
					<?php 
        }
        ?>
					</ul>
				</span>
			</div>		
		<?php 
        $return = ob_get_clean();
        return $return;
    }