Plugin Directory

Changeset 3088341


Ignore:
Timestamp:
05/17/2024 01:11:42 PM (19 months ago)
Author:
viitorcloudvc
Message:

Update date function and Tested with latest WP version

Location:
auto-post-expiration/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • auto-post-expiration/trunk/auto-post-expiration.php

    r3025630 r3088341  
    44 * Plugin URI: https://wordpress.org/plugins/auto-post-expiration/
    55 * Description: This simple plugin allows to set expiry date of post and it set post to "draft" status automatic on desire expire date.
    6  * Version:2.0.0
     6 * Version:3.0.0
    77 * Author: VIITORCLOUD
    88 * Author URI: https://viitorcloud.com/
     
    3939 *
    4040 * @package Auto Post Expiration
    41  * @since 1.0.0
     41 * @since 3.0.0
    4242 */
    4343load_plugin_textdomain( 'auto_post_exp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
     
    4848 *
    4949 * @package Auto Post Expiration
    50  *@since 1.0.0
     50 *@since 3.0.0
    5151 */
    5252register_activation_hook( __FILE__, 'auto_post_exp_install' );
     
    5858 *
    5959 * @package Auto Post Expiration
    60  * @since 1.0.0
     60 * @since 3.0.0
    6161 */
    6262register_deactivation_hook( __FILE__, 'auto_post_exp_uninstall' );
     
    6969 *
    7070 * @package Auto Post Expiration
    71  * @since 1.0.0
     71 * @since 3.0.0
    7272 */
    7373function auto_post_exp_install() {
     
    8282 *
    8383 * @package Auto Post Expiration
    84  * @since 1.0.0
     84 * @since 3.0.0
    8585 */
    8686function auto_post_exp_uninstall() {
     
    9595 *
    9696 * @package Auto Post Expiration
    97  * @since 1.0.0
     97 * @since 3.0.0
    9898 */
    9999
  • auto-post-expiration/trunk/auto-post-expire-options.php

    r3025630 r3088341  
    3030     *
    3131     * @package Auto_Post_Expiration
    32      * @since 1.0.0
     32     * @since 3.0.0
    3333     *
    3434     * @param int $post_id The ID of the post.
     
    3737     */
    3838    function auto_post_exp_cal_datetime( $post_id ) {
    39 
     39        // Get the WordPress timezone string or offset.
    4040        $tz = get_option( 'timezone_string' );
    41         // Change the line below to your timezone!
    42         date_default_timezone_set( $tz );
    43         $field_date  = get_post_meta( $post_id, '_expire_date', true );
    44         $first_date  = new DateTime( current_time( 'mysql' ) );
    45         $second_date = new DateTime( $field_date );
    46         $interval    = $first_date->diff( $second_date );
     41        if ( empty( $tz ) ) {
     42            // If timezone string is empty, fallback to the offset.
     43            $offset = get_option( 'gmt_offset' );
     44            $tz     = $offset ? sprintf( 'Etc/GMT%+d', $offset ) : 'UTC';
     45        }
     46        // Get the current time and the expiration time from the post meta.
     47        $field_date   = get_post_meta( $post_id, '_expire_date', true );
     48        $current_time = current_time( 'mysql' );
     49        // Create DateTime objects using the timezone.
     50        $first_date  = new DateTime( $current_time, new DateTimeZone( $tz ) );
     51        $second_date = new DateTime( $field_date, new DateTimeZone( $tz ) );
     52        // Calculate the interval and return the invert property.
     53        $interval = $first_date->diff( $second_date );
    4754        return $interval->invert;
    4855    }
     
    5360 *
    5461 * @package Auto_Post_Expiration
    55  * @since 1.0.0
     62 * @since 3.0.0
    5663 */
    5764add_action( 'auto_post_exp_add_every_three_minutes', 'auto_post_exp_every_three_minutes_event_func' );
     
    6067 *
    6168 * @package Auto_Post_Expiration
    62  * @since 1.0.0
     69 * @since 3.0.0
    6370 */
    6471function auto_post_exp_every_three_minutes_event_func() {
     
    97104 *
    98105 * @package Auto Post Expiration
    99  * @since 1.0.0
     106 * @since 3.0.0
    100107 * @param WP_Post $post The post object.
    101108 */
     
    118125 *
    119126 * @package Auto_Post_Expiration
    120  * @since 1.0.0
     127 * @since 3.0.0
    121128 */
    122129function auto_post_exp_add_datepicker_scripts() {
     
    125132        plugin_dir_url( __FILE__ ) . 'admin/datetime/css/jquery.datetimepicker.min.css',
    126133        array(),
    127         '2.0.0',
     134        '3.0.0',
     135        'all'
     136    );
     137    wp_enqueue_style(
     138        'vc-styles',
     139        plugin_dir_url( __FILE__ ) . 'admin/css/style.css',
     140        array(),
     141        '3.0.0',
    128142        'all'
    129143    );
     
    132146        plugin_dir_url( __FILE__ ) . 'admin/datetime/js/jquery.datetimepicker.js',
    133147        array( 'jquery' ),
    134         '2.0.0',
     148        '3.0.0',
    135149        true
    136150    );
     
    139153        plugin_dir_url( __FILE__ ) . 'admin/js/custom.js',
    140154        array( 'jquery' ),
    141         '2.0.0',
     155        '3.0.0',
    142156        true
    143157    );
     
    148162 *
    149163 * @package Auto Post Expiration
    150  * @since 1.0.0
     164 * @since 3.0.0
    151165 * @param WP_Post $post The post object.
    152166 */
     
    157171
    158172    $passed_date = get_post_meta( $post->ID, '_expire_date', true );
    159     echo '<input type="text" name="expire_date" id="expire_date"   size="35" value="' . esc_attr( $passed_date ) . '"
     173    echo '<input type="text" name="expire_date" id="expire_date" class="date-vc" size="35" value="' . esc_attr( $passed_date ) . '"
    160174    readonly>';
    161175}
     
    166180 *
    167181 * @package Auto_Post_Expiration
    168  * @since 1.0.0
     182 * @since 3.0.0
    169183 *
    170184 * @param int $post_id The ID of the post.
     
    214228    ** create custom column
    215229     * @package Auto Post Expiration
    216      * @since 1.0.0
     230     * @since 3.0.0
    217231    */
    218232
  • auto-post-expiration/trunk/readme.txt

    r3025630 r3088341  
    44Tags: post_expire, expire, expiration, expire_post, expire_event, post_expire_date, schedule_post, post_draft, set_post_expire 
    55Requires at least: 3.8
    6 Tested up to: 6.4.2
    7 Requires PHP: 5.2.4
    8 Stable tag: 1.0.0 
     6Tested up to: 6.5.3
     7Requires PHP: 7.4.0
     8Stable tag: 6.5.3 
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset for help on using the changeset viewer.