Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter matt_teamworks

    (@matt_teamworks)

    I am using screen_name, it’s set in the widget.

    However if I echo it from within the filter it’s empty…

    But you are right removing the argument all together or setting $screen_name = null in the argument list works.

    I no longer get a warning yet the tweets are still being returned for the correct account.

    Thanks for your help.

    Thread Starter matt_teamworks

    (@matt_teamworks)

    Thanks, in my case something as simple as the below works:

    add_filter( 'latest_tweets_render_list', function( array $items, $screen_name ){
    	// process $items array
    	foreach ($items as $item) {
    		$out .= $item;
    	}
        return $out;
    }, 10 , 1 );

    However I am also getting an error:

    Warning: Missing argument 2 for {closure}()

    matt_teamworks

    (@matt_teamworks)

    Just downloaded the latest version of the plugin from the link below and it’s working now ??

    https://github.com/herewithme/simple-taxonomy

    matt_teamworks

    (@matt_teamworks)

    I’m also getting this error when trying to export.

    Fixed it by changing the opts line in my archivePost function.

    from:

    $opts = 'a:2:{s:10:"expireType";s:7:"archive";s:2:"id";i:'.$post_id.';}';

    to:

    $opts = array(
    	'expireType' => 'archive',
    	'id' => $post_id
    );

    Seems it needs to be an array (not a string as in the first post of this thread).

    It turns out that I’m also able to call the function ‘_scheduleExpiratorEvent’ directly which makes things a bit easier.

    Hi, I’m trying to achieve this exact scenario but I’m also struggling to get the posts to update via wp_schedule_single_event.

    A little background… I’ve created a custom post status called ‘archive’. (I want to be able to archive posts but not have them mixed in with genuine draft posts). In order to get this as an option in the post expirator plugin I had to manually add it to the ‘_postExpiratorExpireType’ and ‘postExpiratorExpire’ functions in post-expirator.php. (This is not ideal as I wanted to avoid editing the plugin file directly – as a future update it would be great if there was a hook to allow adding custom post statuses)

    My custom post status is setup as follows:

    function jc_custom_post_status(){
         register_post_status( 'archive', array(
              'label'                     => _x( 'Archive', 'post' ),
              'public'                    => false,
              'show_in_admin_all_list'    => true,
              'show_in_admin_status_list' => true,
              'label_count'               => _n_noop( 'Archive <span class="count">(%s)</span>', 'Archive <span class="count">(%s)</span>' )
         ) );
    }
    add_action( 'init', 'jc_custom_post_status' );

    I’m creating posts programmatically and setting them to archive as necessary using the following function:

    // archive post
    function archivePost($post_id, $archiveDate) {
    	$expire_time = strtotime(formatTime($archiveDate));
    	$opts = 'a:2:{s:10:"expireType";s:7:"archive";s:2:"id";i:'.$post_id.';}';
    
    	if (wp_next_scheduled('postExpiratorExpire',array($post_id)) !== false) {
    		wp_clear_scheduled_hook('postExpiratorExpire',array($post_id)); //Remove any existing hooks
    	}
    
    	wp_schedule_single_event($expire_time,'postExpiratorExpire',array($post_id)); 
    
    	// Update Post Meta
    	update_post_meta($post_id, '_expiration-date', $expire_time);
    	update_post_meta($post_id, '_expiration-date-options', $opts);
    	update_post_meta($post_id, '_expiration-date-status','saved');
    }

    When I edit the post in the admin I see that the expire posts option is ticked and the date is correct, but the post never expires. If I hit ‘update’ then the post expires as expected.

    It also works fine if I create the post via the wordpress interface instead of programmatically.

    I’ve tried comparing the values stored in wp_postmeta for a post created via the admin and one created programmatically and they appear the same.

    Any suggestions greatly appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)