Beispiel #1
0
/**
 * Filter posts using taxonomy terms.
 *
 * @param array $terms terms to search for in different taxonomies
 * @param string what type of result to generate: count, id, post
 * @return array results mixed
 */
function gdtt_posts_term_filter($terms = array(), $result = "count")
{
    $posts = array();
    foreach ($terms as $tax => $term) {
        $t = gdttDB::get_posts_for_term_by($term["by"], $tax, $term["terms"], "ID");
        if (count($t) == 0) {
            return array();
        }
        if (count($posts) > 0) {
            $posts = array_intersect($posts, $t);
            if (count($posts) == 0) {
                return array();
            }
        } else {
            $posts = $t;
        }
    }
    if ($result == "count") {
        return count($posts);
    }
    if ($result == "id") {
        return $posts;
    }
}
 function init_operations()
 {
     if (isset($_GET["proupgrade"]) && $_GET["proupgrade"] == "hide") {
         $this->o["upgrade_to_pro"] = 0;
         update_option("gd-taxonomy-tools", $this->o);
         wp_redirect(remove_query_arg("proupgrade"));
         exit;
     }
     if (isset($_GET["action"])) {
         $action = $_GET["action"];
         $url = remove_query_arg("action");
         switch ($action) {
             case "delcpt":
                 $id = $this->find_custompost_pos($_GET["pid"]);
                 if ($id > -1) {
                     unset($this->p[$id]);
                     $this->p = array_values($this->p);
                     update_option('gd-taxonomy-tools-cpt', $this->p);
                 }
                 $url = remove_query_arg("pid", $url);
                 wp_redirect($url);
                 exit;
                 break;
             case "deltax":
                 $id = $this->find_taxonomy_pos($_GET["tid"]);
                 if ($id > -1) {
                     $tax_name = $this->t[$id]["name"];
                     unset($this->t[$id]);
                     $this->t = array_values($this->t);
                     update_option('gd-taxonomy-tools-tax', $this->t);
                     gdttDB::delete_taxonomy_terms($tax_name);
                 }
                 $url = remove_query_arg("tid", $url);
                 wp_redirect($url);
                 exit;
                 break;
         }
     }
 }
Beispiel #3
0
 function init_operations()
 {
     global $gdtt;
     if (isset($_GET['proupgradett']) && $_GET['proupgradett'] == 'hide') {
         $gdtt->o['upgrade_to_pro_16'] = 0;
         update_option('gd-taxonomy-tools', $gdtt->o);
         wp_redirect(remove_query_arg('proupgradett'));
         exit;
     }
     if (isset($_GET['notice132gdtt']) && $_GET['notice132gdtt'] == 'hide') {
         $gdtt->o['upgrade_notice_132'] = 0;
         update_option('gd-taxonomy-tools', $gdtt->o);
         wp_redirect(remove_query_arg('notice132gdtt'));
         exit;
     }
     if (isset($_GET['action'])) {
         $action = $_GET['action'];
         $url = remove_query_arg('action');
         switch ($action) {
             case 'delcpt':
                 $id = $gdtt->find_custompost_pos($_GET['pid']);
                 if ($id > -1) {
                     unset($gdtt->p[$id]);
                     $gdtt->p = array_values($gdtt->p);
                     update_option('gd-taxonomy-tools-cpt', $gdtt->p);
                 }
                 $url = remove_query_arg('pid', $url);
                 wp_redirect($url);
                 exit;
                 break;
             case 'deltax':
                 $id = $gdtt->find_taxonomy_pos($_GET['tid']);
                 if ($id > -1) {
                     $tax_name = $gdtt->t[$id]['name'];
                     unset($gdtt->t[$id]);
                     $gdtt->t = array_values($gdtt->t);
                     update_option('gd-taxonomy-tools-tax', $gdtt->t);
                     gdttDB::delete_taxonomy_terms($tax_name);
                 }
                 $url = remove_query_arg('tid', $url);
                 wp_redirect($url);
                 exit;
                 break;
         }
     }
 }
<?php

$post_types = get_post_types(array(), "objects");
$post_count = gdttDB::get_post_types_counts();
echo '<h3>' . __("Default Post Types:", "gd-taxonomies-tools") . '</h3>';
include GDTAXTOOLS_PATH . "forms/render/cpt.header.php";
foreach ($post_types as $cpt_data) {
    $default = true;
    $cpt_name = $cpt_data->name;
    if ($cpt_data->_builtin) {
        include GDTAXTOOLS_PATH . "forms/render/cpt.item.php";
    }
}
include GDTAXTOOLS_PATH . "forms/render/cpt.footer.php";
echo '<h3>' . __("Custom Post Types:", "gd-taxonomies-tools") . '</h3>';
include GDTAXTOOLS_PATH . "forms/render/cpt.header.php";
foreach ($post_types as $cpt_data) {
    $default = false;
    $cpt_name = $cpt_data->name;
    if (!$cpt_data->_builtin) {
        include GDTAXTOOLS_PATH . "forms/render/cpt.item.php";
    }
}
include GDTAXTOOLS_PATH . "forms/render/cpt.footer.php";
?>
<div class="inputbutton" style="margin-top: 10px;"><a href="admin.php?page=gdtaxtools_postypes&action=addnew"><?php 
_e("Add New", "gd-taxonomies-tools");
?>
</a></div>