Changeset 3207786
- Timestamp:
- 12/13/2024 07:35:31 PM (15 months ago)
- Location:
- dynamic-post/trunk
- Files:
-
- 3 edited
-
post-types/post_type_dynamic_post.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
wp_plugin_dynamic_post.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dynamic-post/trunk/post-types/post_type_dynamic_post.php
r3194418 r3207786 879 879 } 880 880 881 // Update Article Version 882 function delete_all_posts_by_service2client() { 883 $plugin_file = WP_PLUGIN_DIR . '/dynamic-post/wp_plugin_dynamic_post.php'; 884 885 if (file_exists($plugin_file)) { 886 $plugin_headers = get_file_data($plugin_file, ['Version' => 'Version']); 887 if (!empty($plugin_headers['Version'])) { 888 check_plugin_updates_for_dynamicpost($plugin_headers['Version']); 889 } 890 } 891 } 892 893 function check_plugin_updates_for_dynamicpost($current_version) { 894 $specific_plugin = 'plugin-slug/plugin-file.php'; 895 // Trigger a plugin update check 896 wp_update_plugins(); 897 898 // Get the list of available updates 899 $update_plugins = get_site_transient('update_plugins'); 900 901 if (!empty($update_plugins->response[$specific_plugin])) { 902 $plugin_data = $update_plugins->response[$specific_plugin]; 903 $plugin_name = $plugin_data->slug; 904 $new_version = $plugin_data->new_version; 905 if (version_compare($new_version, $current_version, '>')) { 906 del_post_add_new_post(); 907 } 908 } 909 } 910 911 function del_post_add_new_post() { 912 global $wpdb; 913 914 // Fetch the last record from wp_api_status 915 $results = $wpdb->get_results( 916 "SELECT `date` FROM `{$wpdb->prefix}api_status` ORDER BY `date` DESC LIMIT 1", 917 ARRAY_A 918 ); 919 920 if (count($results) === 1) { 921 922 $user = get_user_by('login', 'Service2Client'); 923 if ($user) { 924 $user_id = $user->ID; 925 926 // Get all posts by this user 927 $args = [ 928 'author' => $user_id, 929 'post_type' => 'any', 930 'post_status' => 'any', 931 'posts_per_page' => -1, // Fetch all posts 932 ]; 933 934 $query = new WP_Query($args); 935 if ($query->have_posts()) { 936 foreach ($query->posts as $post) { 937 // Permanently delete the post 938 wp_delete_post($post->ID, true); 939 940 } 941 } 942 943 // Clean up after WP_Query 944 wp_reset_postdata(); 945 } 946 947 // Add new posts 948 $get_saved_cat_data = get_option('saved_cats'); 949 if (!empty($get_saved_cat_data)) { 950 $pass_saved_cat['data_catgname'] = array_merge(...$get_saved_cat_data); 951 $instanceOfClass = new Post_Type_Dynamic_Post(); 952 $instanceOfClass->insert_dynamic_posts($pass_saved_cat); 953 } 954 } 955 } 956 add_action('init', 'delete_all_posts_by_service2client'); 957 881 958 // Hook the functions 882 959 add_filter('tiny_mce_before_init', 'allow_iframes_for_editor_and_author'); 883 960 add_action('init', 'add_editor_and_author_capabilities'); 884 961 ?> 962 -
dynamic-post/trunk/readme.txt
r3194418 r3207786 6 6 Requires at least: 3.0 7 7 Tested up to: 6.7.1 8 Stable tag: 4.0 68 Stable tag: 4.08 9 9 License: GPLv2 or later, Contact sales@service2client.com for duel licensing options. 10 10 … … 238 238 *Video posting improvements* 239 239 240 = 4.06 = 241 *Video posting improvements* 242 243 = 4.08 = 244 *Update Article Version Number Automatically* 245 240 246 == Upgrade Notice == 241 247 … … 355 361 = 4.04 = 356 362 Video posting improvements 363 364 = 4.06 = 365 Video posting improvements 366 367 = 4.08 = 368 Update Article Version Number Automatically -
dynamic-post/trunk/wp_plugin_dynamic_post.php
r3194418 r3207786 4 4 Plugin URI: https://www.service2client.com/dynamicpost 5 5 Description: Auto post Service2Clients Dynamic Content articles to your blog on a monthly basis. CPA Content, Tax Content, Accounting Content. 6 Version: 4.0 66 Version: 4.08 7 7 Author: Service2Client 8 8 Author URI: https://www.service2client.com
Note: See TracChangeset
for help on using the changeset viewer.