Changeset 2448087
- Timestamp:
- 12/30/2020 04:47:00 PM (5 years ago)
- Location:
- already-existing-tags/trunk
- Files:
-
- 4 edited
-
admin/already-existing-tags-admin.php (modified) (6 diffs)
-
already-existing-tags-core.php (modified) (3 diffs)
-
already-existing-tags.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
already-existing-tags/trunk/admin/already-existing-tags-admin.php
r2053939 r2448087 1 1 <?php 2 2 defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' ); 3 4 global $aet_included_categories;5 global $aet_halt;6 3 ?> 7 4 … … 17 14 settings_fields( 'aet-settings-group' ); 18 15 19 if ( get_option( 'aet_ automatic_tagging' ) && ! $aet_halt) {20 echo '<h3> Automatic tagging isenabled</h3>';21 } elseif ( get_option( 'aet_ automatic_tagging' ) && $aet_halt) {22 echo '<h3> Automatic tagging isenabled... but no category is selected</h3>';16 if ( 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>'; 23 20 } else { 24 echo '<h3> Automatic tagging isdisabled</h3>';21 echo '<h3>STATUS: disabled</h3>'; 25 22 } 26 23 ?> … … 29 26 <tr> 30 27 <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> 33 30 </td> 34 31 </tr> … … 36 33 <tr> 37 34 <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> 40 37 </td> 41 38 </tr> … … 70 67 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 ) . '"'; 71 68 72 if ( in_array( $value->term_id, $aet_included_categories, true ) ) {69 if ( in_array( $value->term_id, aet_included_categories(), true ) ) { 73 70 echo ' checked="checked"'; 74 71 } … … 89 86 <td> 90 87 <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 optionswon'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> 92 89 </td> 93 90 </tr> -
already-existing-tags/trunk/already-existing-tags-core.php
r2053939 r2448087 2 2 defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' ); 3 3 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; 4 function 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 } 11 12 12 function automatic_tagging( $the_post_id ) { 13 global $aet_included_categories; 13 function aet_halt() { 14 return get_option( 'aet_filter_by_category' ) && empty( aet_included_categories() ); 15 } 14 16 17 function aet_tagging( $the_post_id ) { 15 18 $post = get_post( $the_post_id ); 16 19 … … 32 35 ); 33 36 34 if ( $existing_tags && array_intersect( $post_categories, $aet_included_categories) ) {37 if ( $existing_tags && array_intersect( $post_categories, aet_included_categories() ) ) { 35 38 if ( get_option( 'aet_block_manually_added_tags' ) ) { 36 39 wp_delete_object_term_relationships( $the_post_id, 'post_tag' ); … … 55 58 } 56 59 57 if ( get_option( 'aet_automatic_tagging' ) && ! $aet_halt ) { 58 add_action( 'wp_insert_post', 'automatic_tagging' ); 60 if ( 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 } 59 66 } -
already-existing-tags/trunk/already-existing-tags.php
r2053939 r2448087 4 4 Plugin URI: https://digitalemphasis.com/wordpress-plugins/already-existing-tags/ 5 5 Description: Looks for already existing tags within your posts. 6 Version: 2. 16 Version: 2.2 7 7 Author: digitalemphasis 8 8 Author URI: https://digitalemphasis.com/ … … 11 11 12 12 defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' ); 13 defined( 'AET_PLUGIN_VER' ) || define( 'AET_PLUGIN_VER', '2.2' ); 13 14 14 function aet_ the_settings() {15 register_setting( 'aet-settings-group', 'aet_ automatic_tagging' );15 function aet_register_the_settings() { 16 register_setting( 'aet-settings-group', 'aet_turn_on' ); 16 17 register_setting( 'aet-settings-group', 'aet_block_manually_added_tags' ); 17 18 register_setting( 'aet-settings-group', 'aet_examine_post_title' ); … … 20 21 register_setting( 'aet-settings-group', 'aet_clean_uninstall' ); 21 22 } 22 add_action( 'admin_init', 'aet_ the_settings' );23 add_action( 'admin_init', 'aet_register_the_settings' ); 23 24 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);25 function 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 ); 27 28 } 28 add_action( 'admin_ init', 'aet_admin_init' );29 add_action( 'admin_enqueue_scripts', 'aet_enqueue_assets' ); 29 30 30 31 function aet_settings_page() { 31 include 'admin/already-existing-tags-admin.php';32 require 'admin/already-existing-tags-admin.php'; 32 33 } 33 34 34 function aet_admin_enqueue() { 35 wp_enqueue_style( 'aet-admin-style' ); 36 wp_enqueue_script( 'aet-admin-script' ); 35 function aet_submenu() { 36 add_submenu_page( 'edit.php', 'Already Existing Tags', 'Already Existing Tags', 'manage_options', 'already-existing-tags', 'aet_settings_page' ); 37 37 } 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' ); 38 add_action( 'admin_menu', 'aet_submenu' ); 44 39 45 40 function aet_add_settings_link( $links ) { … … 51 46 52 47 function 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 ) { 54 49 add_option( 'aet_included_categories', get_option( 'aet_automatic_tagging_included_categories' ) ); 55 50 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' ); 56 55 } 57 56 } … … 59 58 60 59 function aet_activation() { 61 add_option( 'aet_ automatic_tagging', '' );60 add_option( 'aet_turn_on', '' ); 62 61 add_option( 'aet_block_manually_added_tags', '' ); 63 62 add_option( 'aet_examine_post_title', '' ); … … 68 67 69 68 function aet_deactivation() { 70 unregister_setting( 'aet-settings-group', 'aet_ automatic_tagging' );69 unregister_setting( 'aet-settings-group', 'aet_turn_on' ); 71 70 unregister_setting( 'aet-settings-group', 'aet_block_manually_added_tags' ); 72 71 unregister_setting( 'aet-settings-group', 'aet_examine_post_title' ); … … 78 77 function aet_uninstall() { 79 78 if ( get_option( 'aet_clean_uninstall' ) ) { 80 delete_option( 'aet_ automatic_tagging' );79 delete_option( 'aet_turn_on' ); 81 80 delete_option( 'aet_block_manually_added_tags' ); 82 81 delete_option( 'aet_examine_post_title' ); -
already-existing-tags/trunk/readme.txt
r2053939 r2448087 4 4 Tags: automatic tags, auto tagger, auto tagging, tagging, tags 5 5 Requires at least: 4.0 6 Tested up to: 5. 17 Stable tag: 2. 16 Tested up to: 5.6 7 Stable tag: 2.2 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 51 51 52 52 == 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. 53 59 54 60 = 2.1 =
Note: See TracChangeset
for help on using the changeset viewer.