예제 #1
0
/**
 * dynwid_term_tree() AJAX lazy loader for Taxonomy terms tree
 * @since 1.5.4.2
 *
 * @return void
 */
function dynwid_term_tree()
{
    include_once DW_MODULES . 'custompost_module.php';
    $DW =& $GLOBALS['DW'];
    $id = isset($_POST['id']) && !empty($_POST['id']) ? sanitize_text_field($_POST['id']) : 0;
    $name = isset($_POST['name']) && !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : '';
    $prefix = isset($_POST['prefix']) && !empty($_POST['prefix']) ? sanitize_text_field($_POST['prefix']) : '';
    $widget_id = isset($_POST['widget_id']) && !empty($_POST['widget_id']) ? sanitize_text_field($_POST['widget_id']) : '';
    if (intval($id) > 0 && !empty($name) && !empty($widget_id)) {
        $opt_tax = $DW->getDWOpt($widget_id, $prefix);
        $opt_tax_childs = $DW->getDWOpt($widget_id, $prefix . '-childs');
        $tree = DW_CustomPost::getTaxChilds($name, array(), $id, array());
        if (count($tree) > 0) {
            DW_CustomPost::prtTax($widget_id, $name, $tree, $opt_tax->act, $opt_tax_childs->act, $prefix);
        }
    }
    die;
}
예제 #2
0
    public static function admin()
    {
        $DW =& $GLOBALS['DW'];
        $widget_id = $GLOBALS['widget_id'];
        parent::admin();
        self::$opt = $DW->getDWOpt($widget_id, 'single');
        $authors = DW_Author::getAuthors();
        if (count($authors) > DW_LIST_LIMIT) {
            $author_condition_select_style = DW_LIST_STYLE;
        }
        $js_count = 0;
        $opt_single_author = $DW->getDWOpt($widget_id, 'single-author');
        $js_author_array = array();
        if ($opt_single_author->count > 0) {
            $js_count = $js_count + $opt_single_author->count - 1;
        }
        // -- Category
        $category = get_categories(array('hide_empty' => FALSE));
        if (count($category) > DW_LIST_LIMIT) {
            $category_condition_select_style = DW_LIST_STYLE;
        }
        // For JS
        $js_category_array = array();
        foreach ($category as $cat) {
            $js_category_array[] = '\'single_category_act_' . $cat->cat_ID . '\'';
            $js_category_array[] = '\'single_category_childs_act_' . $cat->cat_ID . '\'';
        }
        $catmap = DW_Category::getCatChilds(array(), 0, array());
        $opt_single_category = $DW->getDWOpt($widget_id, 'single-category');
        if ($opt_single_category->count > 0) {
            $js_count = $js_count + $opt_single_category->count - 1;
        }
        $opt_single_post = $DW->getDWOpt($widget_id, 'single-post');
        $opt_single_tag = $DW->getDWOpt($widget_id, 'single-tag');
        self::GUIHeader(self::$option[self::$name], self::$question, self::$info);
        self::GUIOption();
        // -- Individual / Posts / Tags
        /*			$opt_individual = $DW->getDWOpt($_GET['id'], 'individual');
        			if ( $opt_individual->count > 0 ) {
        				$individual = TRUE;
        				$count_individual = '(' . __('Posts: ', DW_L10N_DOMAIN) . $opt_single_post->count . ', ' . __('Tags: ', DW_L10N_DOMAIN) . $opt_single_tag->count . ')';
        			}
        
        			// Individual
        			$DW->dumpOpt($opt_individual);
        			echo '<br />';
        			echo '<input type="checkbox" id="individual" name="individual" value="1" ' . ( (isset($individual) && $individual)  ? 'checked="checked"' : '' ) . ' onclick="chkInPosts()" />';
        			echo '<label for="individual">' . __('Make exception rule available to individual posts and tags.', DW_L10N_DOMAIN) . ' ' . ( ($opt_individual->count > 0)  ? $count_individual : '' ) . '</label>';
        			echo '<img src="' . $DW->plugin_url . 'img/info.gif" alt="info" title="' . __('Click to toggle info', DW_L10N_DOMAIN) . '" onclick="divToggle(\'individual_post_tag\')" />';
        */
        /*			echo '<div>';
        			echo '<div id="individual_post_tag" class="infotext">';
        			_e('When you enable this option, you have the ability to apply the exception rule for <em>Single Posts</em> to tags and individual posts.
        								You can set the exception rule for tags in the single Edit Tag Panel (go to <a href="edit-tags.php?taxonomy=post_tag">Post Tags</a>,
        								click a tag), For individual posts in the <a href="post-new.php">New</a> or <a href="edit.php">Edit</a> Posts panel.
        								Exception rules for tags and individual posts in any combination work independantly, but will always be counted as one exception.<br />
        		  					Please note when exception rules are set for Author and/or Category, these will be removed.
        		  				', DW_L10N_DOMAIN);
        		  echo '<br /><br />';
        		  _e('When you have other individual Custom Post Types rules set, this option will be enabled automatically', DW_L10N_DOMAIN);
        
        			echo '</div></div>'; */
        // Individual posts and tags
        foreach ($opt_single_post->act as $singlepost) {
            echo '<input type="hidden" name="single_post_act[]" value="' . $singlepost . '" />';
        }
        foreach ($opt_single_tag->act as $tag) {
            echo '<input type="hidden" name="single_tag_act[]" value="' . $tag . '" />';
        }
        // JS array authors
        foreach (array_keys($authors) as $id) {
            $js_author_array[] = '\'single_author_act_' . $id . '\'';
        }
        ?>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
  <td valign="top">
  	<?php 
        DW_Author::mkGUI(TRUE);
        ?>
  </td>
  <td style="width:10px"></td>
  <td valign="top">
  	<?php 
        $opt = $DW->getDWOpt($widget_id, 'single-category');
        ?>
  	<?php 
        $DW->dumpOpt($opt);
        ?>
		<?php 
        DW_Category::GUIComplex(TRUE, $opt);
        ?>
    </div>
  </td>
</tr>
</table>
<?php 
        $type = 'post';
        $tax_list = get_object_taxonomies($type, 'objects');
        foreach ($tax_list as $tax_type) {
            if ($tax_type->name != 'post_tag' && $tax_type->name != 'category') {
                // Prepare
                $opt_tax = $DW->getDWOpt($widget_id, 'single-tax_' . $tax_type->name);
                if ($tax_type->hierarchical) {
                    $opt_tax_childs = $DW->getDWOpt($widget_id, 'single-tax_' . $tax_type->name . '-childs');
                } else {
                    unset($opt_tax_childs);
                }
                $tax = get_terms($tax_type->name, array('get' => 'all'));
                if (count($tax) > 0) {
                    if (count($tax) > DW_LIST_LIMIT) {
                        $tax_condition_select_style = DW_LIST_STYLE;
                    }
                    $tree = DW_CustomPost::getTaxChilds($tax_type->name, array(), 0, array());
                    echo '<br />';
                    $DW->dumpOpt($opt_tax);
                    if (isset($opt_tax_childs)) {
                        $DW->dumpOpt($opt_tax_childs);
                    }
                    echo '<input type="hidden" name="single_tax_list[]" value="single-tax_' . $tax_type->name . '" />';
                    echo __('Except for', DW_L10N_DOMAIN) . ' ' . $tax_type->label . ':<br />';
                    echo '<div id="single-tax_' . $tax_type->name . '-select" class="condition-select" ' . (isset($tax_condition_select_style) ? $tax_condition_select_style : '') . '>';
                    echo '<div style="position:relative;left:-15px">';
                    if (!isset($opt_tax_childs)) {
                        $childs = FALSE;
                    } else {
                        $childs = $opt_tax_childs->act;
                    }
                    DW_CustomPost::prtTax($tax_type->name, $tree, $opt_tax->act, $childs, 'single-tax_' . $tax_type->name);
                    echo '</div>';
                    echo '</div>';
                }
            }
        }
        self::GUIFooter();
        ?>
<script type="text/javascript">
/* <![CDATA[ */
  function chkInPosts() {
    var posts = <?php 
        echo $opt_single_post->count;
        ?>
;
    var tags = <?php 
        echo $opt_single_tag->count;
        ?>
;

    if ( (posts > 0 || tags > 0) && jQuery('#individual').is(':checked') == false ) {
      if ( confirm('Are you sure you want to disable the exception rule for individual posts and tags?\nThis will remove the options set to individual posts and/or tags for this widget.\nOk = Yes; No = Cancel') ) {
        swChb(cAuthors, false);
        swChb(cCat, false);
      } else {
        jQuery('#individual').attr('checked', true);
      }
    } else if ( icount > 0 && jQuery('#individual').is(':checked') ) {
      if ( confirm('Are you sure you want to enable the exception rule for individual posts and tags?\nThis will remove the exceptions set for Author and/or Category on single posts for this widget.\nOk = Yes; No = Cancel') ) {
        swChb(cAuthors, true);
        swChb(cCat, true);
        icount = 0;
      } else {
        jQuery('#individual').attr('checked', false);
      }
    } else if ( jQuery('#individual').is(':checked') ) {
        swChb(cAuthors, true);
        swChb(cCat, true);
    } else {
        swChb(cAuthors, false);
        swChb(cCat, false);
    }
  }

 	function ci(id) {
    if ( jQuery('#'+id).is(':checked') ) {
      icount++;
    } else {
      icount--;
    }
  }

  var icount = <?php 
        echo $js_count;
        ?>
;
  var cAuthors = new Array(<?php 
        echo implode(', ', $js_author_array);
        ?>
);
  var cCat = new Array(<?php 
        echo implode(', ', $js_category_array);
        ?>
);

  if ( jQuery('#individual').is(':checked') ) {
    swChb(cAuthors, true);
    swChb(cCat, true);
  }

  if ( jQuery('#single-yes').is(':checked') && jQuery('#single_conf :checkbox').is(':checked')  ) {
  	jQuery('#single').append( ' <img src="<?php 
        echo $DW->plugin_url;
        ?>
img/checkmark.gif" alt="Checkmark" />' );
  }
/* ]]> */
</script>
<?php 
    }
    public static function admin()
    {
        $DW =& $GLOBALS['DW'];
        parent::admin();
        self::$opt = $DW->getDWOpt($GLOBALS['widget_id'], 'page');
        self::$opt_page = self::$opt;
        if (self::$opt->count > 0) {
            self::$opt_page_childs = $DW->getDWOpt($GLOBALS['widget_id'], 'page-childs');
        }
        $pages = get_pages(array('post_status' => 'publish,private'));
        $num_pages = count($pages);
        unset($pages);
        if ($num_pages < DW_PAGE_LIMIT) {
            $hierarchy = TRUE;
        } else {
            $hierarchy = FALSE;
        }
        // For childs we double the number of pages because of addition of 'All childs' option
        if ($hierarchy && $num_pages * 2 > DW_LIST_LIMIT || $num_pages > DW_LIST_LIMIT) {
            $page_condition_select_style = DW_LIST_STYLE;
        }
        self::$static_page = array();
        if (get_option('show_on_front') == 'page') {
            $id = get_option('page_on_front');
            self::$static_page[$id] = __('Front page', DW_L10N_DOMAIN);
            if (get_option('page_on_front') == get_option('page_for_posts')) {
                self::$static_page[$id] .= ', ' . __('Posts page', DW_L10N_DOMAIN);
            }
        }
        if ($num_pages < DW_PAGE_LIMIT) {
            $childs_infotext = self::infoText();
        } else {
            $childs_infotext = __('Unfortunately the childs-function has been disabled
						because you have more than the limit of pages.', DW_L10N_DOMAIN) . '(' . DW_PAGE_LIMIT . ')';
        }
        self::$info = $childs_infotext;
        self::GUIHeader(self::$option[self::$name], self::$question, self::$info);
        self::GUIOption();
        if ($num_pages > 0) {
            $DW->dumpOpt(self::$opt_page_childs);
            echo '<br />';
            _e('Except the page(s)', DW_L10N_DOMAIN);
            echo '<br />';
            echo '<div id="page-select" class="condition-select" ' . (isset($page_condition_select_style) ? $page_condition_select_style : '') . ' />';
            if ($num_pages < DW_PAGE_LIMIT) {
                wp_list_pages(array('title_li' => '', 'post_status' => 'publish,private', 'walker' => new DW_Page_Walker()));
            } else {
                wp_list_pages(array('title_li' => '', 'post_status' => 'publish,private', 'depth' => -1, 'walker' => new DW_Page_Walker()));
            }
            echo '</div>';
        }
        $tax_list = get_object_taxonomies('page', 'objects');
        foreach ($tax_list as $tax_type) {
            // Prepare
            $opt_tax = $DW->getDWOpt($_GET['id'], 'page-tax_' . $tax_type->name);
            if ($tax_type->hierarchical) {
                $opt_tax_childs = $DW->getDWOpt($_GET['id'], 'page-tax_' . $tax_type->name . '-childs');
            } else {
                unset($opt_tax_childs);
            }
            $tax = get_terms($tax_type->name, array('get' => 'all'));
            if (count($tax) > 0) {
                if (count($tax) > DW_LIST_LIMIT) {
                    $tax_condition_select_style = DW_LIST_STYLE;
                }
                $tree = DW_CustomPost::getTaxChilds($tax_type->name, array(), 0, array());
                echo '<br />';
                $DW->dumpOpt($opt_tax);
                if (isset($opt_tax_childs)) {
                    $DW->dumpOpt($opt_tax_childs);
                }
                echo '<input type="hidden" name="page_tax_list[]" value="page-tax_' . $tax_type->name . '" />';
                echo __('Except for', DW_L10N_DOMAIN) . ' ' . $tax_type->label . ':<br />';
                echo '<div id="page-tax_' . $tax_type->name . '-select" class="condition-select" ' . (isset($tax_condition_select_style) ? $tax_condition_select_style : '') . '>';
                echo '<div style="position:relative;left:-15px">';
                if (!isset($opt_tax_childs)) {
                    $childs = FALSE;
                } else {
                    $childs = $opt_tax_childs->act;
                }
                echo '<input type="hidden" id="page-tax_' . $tax_type->name . '_act" name="page-tax_' . $tax_type->name . '_act" value="' . implode(',', $opt_tax->act) . '" />';
                if (isset($opt_tax_childs)) {
                    echo '<input type="hidden" id="page-tax_' . $tax_type->name . '_childs_act" name="page-tax_' . $tax_type->name . '_childs_act" value="' . implode(',', $opt_tax_childs->act) . '" />';
                }
                // DW_CustomPost::prtTax($tax_type->name, $tree, $opt_tax->act, $childs, 'page-tax_' . $tax_type->name);
                DW_CustomPost::prtTax($widget_id, $tax_type->name, $tree, $opt_tax->act, $childs, 'page-tax_' . $tax_type->name);
                echo '</div>';
                echo '</div>';
            }
        }
        self::GUIFooter();
    }
    public static function admin()
    {
        $DW =& $GLOBALS['DW'];
        $widget_id = $GLOBALS['widget_id'];
        parent::admin();
        self::$opt = $DW->getDWOpt($widget_id, 'single');
        $authors = DW_Author::getAuthors();
        if (count($authors) > DW_LIST_LIMIT) {
            $author_condition_select_style = DW_LIST_STYLE;
        }
        $js_count = 0;
        $opt_single_author = $DW->getDWOpt($widget_id, 'single-author');
        $js_author_array = array();
        if ($opt_single_author->count > 0) {
            $js_count = $js_count + $opt_single_author->count - 1;
        }
        // -- Category
        $category = get_categories(array('hide_empty' => FALSE));
        if (count($category) > DW_LIST_LIMIT) {
            $category_condition_select_style = DW_LIST_STYLE;
        }
        // For JS
        $js_category_array = array();
        foreach ($category as $cat) {
            $js_category_array[] = '\'single_category_act_' . $cat->cat_ID . '\'';
            $js_category_array[] = '\'single_category_childs_act_' . $cat->cat_ID . '\'';
        }
        $catmap = DW_Category::getCatChilds(array(), 0, array());
        $opt_single_category = $DW->getDWOpt($widget_id, 'single-category');
        if ($opt_single_category->count > 0) {
            $js_count = $js_count + $opt_single_category->count - 1;
        }
        $opt_single_post = $DW->getDWOpt($widget_id, 'single-post');
        $opt_single_tag = $DW->getDWOpt($widget_id, 'single-tag');
        self::GUIHeader(self::$option[self::$name], self::$question, self::$info);
        self::GUIOption();
        // Individual posts and tags
        foreach ($opt_single_post->act as $singlepost) {
            echo '<input type="hidden" name="single_post_act[]" value="' . $singlepost . '" />';
        }
        foreach ($opt_single_tag->act as $tag) {
            echo '<input type="hidden" name="single_tag_act[]" value="' . $tag . '" />';
        }
        // JS array authors
        foreach (array_keys($authors) as $id) {
            $js_author_array[] = '\'single_author_act_' . $id . '\'';
        }
        ?>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
  <td valign="top">
  	<?php 
        DW_Author::mkGUI(self::$type, self::$option[self::$name], self::$question, TRUE);
        ?>
  </td>
  <td style="width:10px"></td>
  <td valign="top">
  	<?php 
        $opt = $DW->getDWOpt($widget_id, 'single-category');
        ?>
  	<?php 
        $DW->dumpOpt($opt);
        ?>
		<?php 
        DW_Category::GUIComplex(NULL, NULL, TRUE, $opt);
        ?>
    </div>
  </td>
</tr>
</table>
<?php 
        $type = 'post';
        $tax_list = get_object_taxonomies($type, 'objects');
        $tax_list = apply_filters('dynwid_taxonomies', $tax_list);
        foreach ($tax_list as $tax_type) {
            if ($tax_type->name != 'post_tag' && $tax_type->name != 'category') {
                // Prepare
                $opt_tax = $DW->getDWOpt($widget_id, 'single-tax_' . $tax_type->name);
                if ($tax_type->hierarchical) {
                    $opt_tax_childs = $DW->getDWOpt($widget_id, 'single-tax_' . $tax_type->name . '-childs');
                } else {
                    unset($opt_tax_childs);
                }
                $tax = get_terms($tax_type->name, array('get' => 'all'));
                if (count($tax) > 0) {
                    if (count($tax) > DW_LIST_LIMIT) {
                        $tax_condition_select_style = DW_LIST_STYLE;
                    }
                    $tree = DW_CustomPost::getTaxChilds($tax_type->name, array(), 0, array());
                    echo '<br />';
                    $DW->dumpOpt($opt_tax);
                    if (isset($opt_tax_childs)) {
                        $DW->dumpOpt($opt_tax_childs);
                    }
                    echo '<input type="hidden" name="single_tax_list[]" value="single-tax_' . $tax_type->name . '" />';
                    echo __('Except for', DW_L10N_DOMAIN) . ' ' . $tax_type->label . ':<br />';
                    echo '<div id="single-tax_' . $tax_type->name . '-select" class="condition-select" ' . (isset($tax_condition_select_style) ? $tax_condition_select_style : '') . '>';
                    echo '<div style="position:relative;left:-15px">';
                    if (!isset($opt_tax_childs)) {
                        $childs = FALSE;
                    } else {
                        $childs = $opt_tax_childs->act;
                    }
                    echo '<input type="hidden" id="single-tax_' . $tax_type->name . '_act" name="single-tax_' . $tax_type->name . '_act" value="' . implode(',', $opt_tax->act) . '" />';
                    if (isset($opt_tax_childs)) {
                        echo '<input type="hidden" id="single-tax_' . $tax_type->name . '_childs_act" name="single-tax_' . $tax_type->name . '_childs_act" value="' . implode(',', $opt_tax_childs->act) . '" />';
                    }
                    DW_CustomPost::prtTax($widget_id, $tax_type->name, $tree, $opt_tax->act, $childs, 'single-tax_' . $tax_type->name);
                    echo '</div>';
                    echo '</div>';
                }
            }
        }
        // foreach
        self::GUIFooter();
        ?>
<script type="text/javascript">
/* <![CDATA[ */
  function chkInPosts() {
    var posts = <?php 
        echo $opt_single_post->count;
        ?>
;
    var tags = <?php 
        echo $opt_single_tag->count;
        ?>
;

    if ( (posts > 0 || tags > 0) && jQuery('#individual').is(':checked') == false ) {
      if ( confirm('Are you sure you want to disable the exception rule for individual posts and tags?\nThis will remove the options set to individual posts and/or tags for this widget.\nOk = Yes; No = Cancel') ) {
        swChb(cAuthors, false);
        swChb(cCat, false);
      } else {
        jQuery('#individual').attr('checked', true);
      }
    } else if ( icount > 0 && jQuery('#individual').is(':checked') ) {
      if ( confirm('Are you sure you want to enable the exception rule for individual posts and tags?\nThis will remove the exceptions set for Author and/or Category on single posts for this widget.\nOk = Yes; No = Cancel') ) {
        swChb(cAuthors, true);
        swChb(cCat, true);
        icount = 0;
      } else {
        jQuery('#individual').attr('checked', false);
      }
    } else if ( jQuery('#individual').is(':checked') ) {
        swChb(cAuthors, true);
        swChb(cCat, true);
    } else {
        swChb(cAuthors, false);
        swChb(cCat, false);
    }
  }

 	function ci(id) {
    if ( jQuery('#'+id).is(':checked') ) {
      icount++;
    } else {
      icount--;
    }
  }

  var icount = <?php 
        echo $js_count;
        ?>
;
  var cAuthors = new Array(<?php 
        echo implode(', ', $js_author_array);
        ?>
);
  var cCat = new Array(<?php 
        echo implode(', ', $js_category_array);
        ?>
);

  if ( jQuery('#individual').is(':checked') ) {
    swChb(cAuthors, true);
    swChb(cCat, true);
  }

  if ( jQuery('#single-yes').is(':checked') && jQuery('#single_conf :checkbox').is(':checked')  ) {
  	jQuery('#single').append( ' <img src="<?php 
        echo $DW->plugin_url;
        ?>
img/checkmark.gif" alt="Checkmark" />' );
  }
/* ]]> */
</script>
<?php 
    }