Skip to content

Commit

Permalink
Deprecated wick. Use category names instead for exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Sep 21, 2016
1 parent 812e386 commit 4ceec56
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 582 deletions.
49 changes: 19 additions & 30 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@ function tptn_options() {

/**** Exclude categories ****/
$exclude_categories_slugs = array_map( 'trim', explode( ',', sanitize_text_field( $_POST['exclude_cat_slugs'] ) ) );
$tptn_settings['exclude_cat_slugs'] = implode( ', ', $exclude_categories_slugs );

foreach ( $exclude_categories_slugs as $exclude_categories_slug ) {
$category_obj = get_category_by_slug( $exclude_categories_slug );
if ( isset( $category_obj->term_taxonomy_id ) ) { $exclude_categories[] = $category_obj->term_taxonomy_id; }
$category_obj = get_term_by( 'name', $exclude_categories_slug, 'category' );

// Fall back to slugs since that was the default format before v2.4.0.
if ( false === $category_obj ) {
$category_obj = get_term_by( 'slug', $exclude_categories_slug, 'category' );
}
if ( isset( $category_obj->term_taxonomy_id ) ) {
$exclude_categories[] = $category_obj->term_taxonomy_id;
$exclude_cat_slugs[] = $category_obj->name;
}
}
$tptn_settings['exclude_categories'] = ( isset( $exclude_categories ) ) ? join( ',', $exclude_categories ) : '';
$tptn_settings['exclude_cat_slugs'] = ( isset( $exclude_cat_slugs ) ) ? join( ',', $exclude_cat_slugs ) : '';

$tptn_settings['title'] = wp_kses_post( $_POST['title'] );
$tptn_settings['title_daily'] = wp_kses_post( $_POST['title_daily'] );
Expand Down Expand Up @@ -497,6 +505,7 @@ function tptn_adminhead() {
wp_enqueue_script( 'wp-lists' );
wp_enqueue_script( 'postbox' );
wp_enqueue_script( 'plugin-install' );
wp_enqueue_script( 'suggest' );

add_thickbox();

Expand Down Expand Up @@ -538,23 +547,21 @@ function tptn_adminhead() {
// postboxes setup
postboxes.add_postbox_toggles('tptn_options');
});
//]]>
</script>

<script type="text/javascript" language="JavaScript">
//<![CDATA[
// Function to add auto suggest.
function setSuggest( id, taxonomy ) {
jQuery('#' + id).suggest("<?php echo admin_url( 'admin-ajax.php?action=ajax-tag-search&tax=' ); ?>" + taxonomy, {multiple:true, multipleSep: ","});
}

// Function check the form submission.
function checkForm() {
answer = true;
if (siw && siw.selectingSomething)
answer = false;
return answer;
} //
//]]>
</script>

<link rel="stylesheet" type="text/css" href="<?php echo TOP_TEN_PLUGIN_URL ?>/admin/wick/wick.css" />
<script type="text/javascript" language="JavaScript">
//<![CDATA[
// Function to clear the cache.
function clearCache() {
/**** since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php ****/
jQuery.post(ajaxurl, {
Expand All @@ -563,27 +570,9 @@ function clearCache() {
alert(response.message);
}, 'json');
}

<?php
function wick_data() {

$categories = get_categories( 'hide_empty=0' );
$str = 'collection = [';
foreach ( $categories as $cat ) {
$str .= "'" . $cat->slug . "',";
}
$str = substr( $str, 0, -1 ); // Remove trailing comma.
$str .= '];';

echo $str;
}
wick_data();
?>
//]]>
</script>

<script type="text/javascript" src="<?php echo TOP_TEN_PLUGIN_URL ?>/admin/wick/wick.js"></script>

<?php
}

Expand Down
19 changes: 3 additions & 16 deletions admin/main-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,8 @@
<tr>
<th scope="row"><label for="exclude_cat_slugs"><?php esc_html_e( 'Exclude Categories:', 'top-10' ); ?></label></th>
<td>
<div style="position:relative;text-align:left">
<table id="MYCUSTOMFLOATER" class="myCustomFloater" style="position:absolute;top:50px;left:0;background-color:#cecece;display:none;visibility:hidden">
<tr><td><!--
please see: http://chrisholland.blogspot.com/2004/09/geekstuff-css-display-inline-block.html
to explain why i'm using a table here.
You could replace the table/tr/td with a DIV, but you'd have to specify it's width and height
-->
<div class="myCustomFloaterContent">
you should never be seeing this
</div>
</td></tr>
</table>
<textarea class="wickEnabled:MYCUSTOMFLOATER" cols="50" rows="3" wrap="virtual" name="exclude_cat_slugs" style="width:100%"><?php echo esc_textarea( $tptn_settings['exclude_cat_slugs'] ); ?></textarea>
<p class="description"><?php esc_html_e( 'Comma separated list of category slugs. The field above has an autocomplete so simply start typing in the starting letters and it will prompt you with options', 'top-10' ); ?></p>
</div>
<label><input type="textbox" name="exclude_cat_slugs" id="exclude_cat_slugs" value="<?php echo esc_attr( $tptn_settings['exclude_cat_slugs'] ); ?>" onfocus="setSuggest('exclude_cat_slugs', 'category');" class="widefat"></label>
<p class="description"><?php esc_html_e( 'Comma separated list of category names. The field above has an autocomplete so simply start typing in the starting letters and it will prompt you with options. Does not support tags or custom taxonomies.', 'top-10' ); ?></p>
<p class="description highlight">
<?php
esc_html_e( 'Excluded category IDs are:', 'top-10' );
Expand All @@ -375,7 +362,7 @@
</p>
<p class="description">
<?php
esc_html_e( 'These might differ from the IDs visible in the Categories page which use the <code>term_id</code>. Top 10 uses the <code>term_taxonomy_id</code> which is unique to this taxonomy.', 'top-10' );
printf( esc_html__( 'These might differ from the IDs visible in the Categories page which use the %s. Top 10 uses the %s which is unique to this taxonomy.', 'top-10' ), '<code>term_id</code>', '<code>term_taxonomy_id</code>' ); ?>
?>
</p>
</td>
Expand Down
1 change: 0 additions & 1 deletion admin/wick/index.php

This file was deleted.

50 changes: 0 additions & 50 deletions admin/wick/wick.css

This file was deleted.

Loading

0 comments on commit 4ceec56

Please sign in to comment.