Plugin Directory

Changeset 2448087


Ignore:
Timestamp:
12/30/2020 04:47:00 PM (5 years ago)
Author:
digitalemphasis
Message:

adding 2.2 release

Location:
already-existing-tags/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • already-existing-tags/trunk/admin/already-existing-tags-admin.php

    r2053939 r2448087  
    11<?php
    22defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' );
    3 
    4 global $aet_included_categories;
    5 global $aet_halt;
    63?>
    74
     
    1714settings_fields( 'aet-settings-group' );
    1815
    19 if ( get_option( 'aet_automatic_tagging' ) && ! $aet_halt ) {
    20     echo '<h3>Automatic tagging is enabled</h3>';
    21 } elseif ( get_option( 'aet_automatic_tagging' ) && $aet_halt ) {
    22     echo '<h3>Automatic tagging is enabled... but no category is selected</h3>';
     16if ( get_option( 'aet_turn_on' ) && ! aet_halt() ) {
     17    echo '<h3>STATUS: enabled</h3>';
     18} elseif ( get_option( 'aet_turn_on' ) && aet_halt() ) {
     19    echo '<h3>STATUS: enabled... but no category is selected</h3>';
    2320} else {
    24     echo '<h3>Automatic tagging is disabled</h3>';
     21    echo '<h3>STATUS: disabled</h3>';
    2522}
    2623?>
     
    2926<tr>
    3027<td>
    31 <input type="checkbox" id="aet-automatic-tagging" name="aet_automatic_tagging" value="1"<?php checked( get_option( 'aet_automatic_tagging' ) ); ?> />
    32 <label for="aet-automatic-tagging">Automatic tagging.</label>
     28<input type="checkbox" id="aet-turn-on" name="aet_turn_on" value="1"<?php checked( get_option( 'aet_turn_on' ) ); ?> />
     29<label for="aet-turn-on">Turn on.</label>
    3330</td>
    3431</tr>
     
    3633<tr>
    3734<td>
    38 <input type="checkbox" id="aet_block_manually_added_tags" name="aet_block_manually_added_tags" value="1"<?php checked( get_option( 'aet_block_manually_added_tags' ) ); ?> />
    39 <label for="aet_block_manually_added_tags">Block manually added tags.</label>
     35<input type="checkbox" id="aet-block-manually-added-tags" name="aet_block_manually_added_tags" value="1"<?php checked( get_option( 'aet_block_manually_added_tags' ) ); ?> />
     36<label for="aet-block-manually-added-tags">Block manually added tags (previously assigned tags will also be removed when the post is updated).</label>
    4037</td>
    4138</tr>
     
    7067    echo '<input type="checkbox" class="chkbx" id="aet-included-categories-' . esc_attr( $value->term_id ) . '" name="aet_included_categories[]" value="' . esc_attr( $value->term_id ) . '"';
    7168
    72     if ( in_array( $value->term_id, $aet_included_categories, true ) ) {
     69    if ( in_array( $value->term_id, aet_included_categories(), true ) ) {
    7370        echo ' checked="checked"';
    7471    }
     
    8986<td>
    9087<input type="checkbox" id="aet-clean-uninstall" name="aet_clean_uninstall" value="1"<?php checked( get_option( 'aet_clean_uninstall' ) ); ?> />
    91 <label for="aet-clean-uninstall">Delete all options from database when you delete this plugin (the options won't be deleted on just deactivation).</label>
     88<label for="aet-clean-uninstall">Delete all options from database when you delete this plugin (they won't be deleted on just deactivation).</label>
    9289</td>
    9390</tr>
  • already-existing-tags/trunk/already-existing-tags-core.php

    r2053939 r2448087  
    22defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' );
    33
    4 $aet_included_categories = ( get_option( 'aet_included_categories' ) ) ? array_map(
    5     function( $cat_id ) {
    6         return + $cat_id;
    7     },
    8     get_option( 'aet_included_categories' )
    9 ) : array();
    10 $aet_halt                = ( get_option( 'aet_filter_by_category' ) && empty( $aet_included_categories ) ) ? true : false;
     4function aet_included_categories() {
     5    return get_option( 'aet_included_categories' ) ? array_map(
     6        function( $cat_id ) {
     7            return + $cat_id;
     8        },
     9        get_option( 'aet_included_categories' )
     10    ) : array();
     11}
    1112
    12 function automatic_tagging( $the_post_id ) {
    13     global $aet_included_categories;
     13function aet_halt() {
     14    return get_option( 'aet_filter_by_category' ) && empty( aet_included_categories() );
     15}
    1416
     17function aet_tagging( $the_post_id ) {
    1518    $post = get_post( $the_post_id );
    1619
     
    3235        );
    3336
    34         if ( $existing_tags && array_intersect( $post_categories, $aet_included_categories ) ) {
     37        if ( $existing_tags && array_intersect( $post_categories, aet_included_categories() ) ) {
    3538            if ( get_option( 'aet_block_manually_added_tags' ) ) {
    3639                wp_delete_object_term_relationships( $the_post_id, 'post_tag' );
     
    5558}
    5659
    57 if ( get_option( 'aet_automatic_tagging' ) && ! $aet_halt ) {
    58     add_action( 'wp_insert_post', 'automatic_tagging' );
     60if ( get_option( 'aet_turn_on' ) && ! aet_halt() ) {
     61    if ( function_exists( 'wp_after_insert_post' ) ) {
     62        add_action( 'wp_after_insert_post', 'aet_tagging' );
     63    } else {
     64        add_action( 'wp_insert_post', 'aet_tagging' );
     65    }
    5966}
  • already-existing-tags/trunk/already-existing-tags.php

    r2053939 r2448087  
    44Plugin URI: https://digitalemphasis.com/wordpress-plugins/already-existing-tags/
    55Description: Looks for already existing tags within your posts.
    6 Version: 2.1
     6Version: 2.2
    77Author: digitalemphasis
    88Author URI: https://digitalemphasis.com/
     
    1111
    1212defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' );
     13defined( 'AET_PLUGIN_VER' ) || define( 'AET_PLUGIN_VER', '2.2' );
    1314
    14 function aet_the_settings() {
    15     register_setting( 'aet-settings-group', 'aet_automatic_tagging' );
     15function aet_register_the_settings() {
     16    register_setting( 'aet-settings-group', 'aet_turn_on' );
    1617    register_setting( 'aet-settings-group', 'aet_block_manually_added_tags' );
    1718    register_setting( 'aet-settings-group', 'aet_examine_post_title' );
     
    2021    register_setting( 'aet-settings-group', 'aet_clean_uninstall' );
    2122}
    22 add_action( 'admin_init', 'aet_the_settings' );
     23add_action( 'admin_init', 'aet_register_the_settings' );
    2324
    24 function aet_admin_init() {
    25     wp_register_style( 'aet-admin-style', plugins_url( 'admin/already-existing-tags-admin.css', __FILE__ ), array(), null );
    26     wp_register_script( 'aet-admin-script', plugins_url( 'admin/already-existing-tags-admin.js', __FILE__ ), array(), null );
     25function aet_enqueue_assets() {
     26    wp_enqueue_style( 'aet-admin-style', plugins_url( 'admin/already-existing-tags-admin.css', __FILE__ ), array(), AET_PLUGIN_VER );
     27    wp_enqueue_script( 'aet-admin-script', plugins_url( 'admin/already-existing-tags-admin.js', __FILE__ ), array( 'jquery' ), AET_PLUGIN_VER, true );
    2728}
    28 add_action( 'admin_init', 'aet_admin_init' );
     29add_action( 'admin_enqueue_scripts', 'aet_enqueue_assets' );
    2930
    3031function aet_settings_page() {
    31     include 'admin/already-existing-tags-admin.php';
     32    require 'admin/already-existing-tags-admin.php';
    3233}
    3334
    34 function aet_admin_enqueue() {
    35     wp_enqueue_style( 'aet-admin-style' );
    36     wp_enqueue_script( 'aet-admin-script' );
     35function aet_submenu() {
     36    add_submenu_page( 'edit.php', 'Already Existing Tags', 'Already Existing Tags', 'manage_options', 'already-existing-tags', 'aet_settings_page' );
    3737}
    38 
    39 function aet_menu() {
    40     $page = add_submenu_page( 'edit.php', 'Already Existing Tags', 'Already Existing Tags', 'manage_options', 'already-existing-tags', 'aet_settings_page' );
    41     add_action( 'load-' . $page, 'aet_admin_enqueue' );
    42 }
    43 add_action( 'admin_menu', 'aet_menu' );
     38add_action( 'admin_menu', 'aet_submenu' );
    4439
    4540function aet_add_settings_link( $links ) {
     
    5146
    5247function aet_update_db_check() {
    53     if ( get_option( 'aet_automatic_tagging_included_categories' ) || get_option( 'aet_automatic_tagging_included_categories' ) === '' ) {
     48    if ( get_option( 'aet_automatic_tagging_included_categories' ) !== false ) {
    5449        add_option( 'aet_included_categories', get_option( 'aet_automatic_tagging_included_categories' ) );
    5550        delete_option( 'aet_automatic_tagging_included_categories' );
     51    }
     52    if ( get_option( 'aet_automatic_tagging' ) !== false ) {
     53        add_option( 'aet_turn_on', get_option( 'aet_automatic_tagging' ) );
     54        delete_option( 'aet_automatic_tagging' );
    5655    }
    5756}
     
    5958
    6059function aet_activation() {
    61     add_option( 'aet_automatic_tagging', '' );
     60    add_option( 'aet_turn_on', '' );
    6261    add_option( 'aet_block_manually_added_tags', '' );
    6362    add_option( 'aet_examine_post_title', '' );
     
    6867
    6968function aet_deactivation() {
    70     unregister_setting( 'aet-settings-group', 'aet_automatic_tagging' );
     69    unregister_setting( 'aet-settings-group', 'aet_turn_on' );
    7170    unregister_setting( 'aet-settings-group', 'aet_block_manually_added_tags' );
    7271    unregister_setting( 'aet-settings-group', 'aet_examine_post_title' );
     
    7877function aet_uninstall() {
    7978    if ( get_option( 'aet_clean_uninstall' ) ) {
    80         delete_option( 'aet_automatic_tagging' );
     79        delete_option( 'aet_turn_on' );
    8180        delete_option( 'aet_block_manually_added_tags' );
    8281        delete_option( 'aet_examine_post_title' );
  • already-existing-tags/trunk/readme.txt

    r2053939 r2448087  
    44Tags:  automatic tags, auto tagger, auto tagging, tagging, tags
    55Requires at least: 4.0
    6 Tested up to: 5.1
    7 Stable tag: 2.1
     6Tested up to: 5.6
     7Stable tag: 2.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5151
    5252== Changelog ==
     53
     54= 2.2 =
     55* Ensure compatibility with WordPress 5.2, 5.3, 5.4, 5.5 and 5.6
     56* From now on, the plugin uses the new 'wp_after_insert_post' function (WordPress >= 5.6) if available.
     57* Better explained settings.
     58* Code optimization.
    5359
    5460= 2.1 =
Note: See TracChangeset for help on using the changeset viewer.