• Resolved gkhairallah

    (@gkhairallah)


    Hello,

    I’ve been looking for a subscribe plugin for a while, and subscribe2 really fit the bill, and it’s working perfectly.
    Here’s my problem though, I have a wordpress instance which I’m using internally for publishing system status updates, using the Service Status plugin: http://wordpress.org/extend/plugins/service-status/

    I’m not too well versed with PHP or the WordPress codex to be able to decipher what’s going on here, but, the status update plugin creates a new post type in the left pane on the admin navigation bar. (i.e: there is the Pages –> All Pages / Add New / , Posts –> All Posts / Add New / Categories / Tags, and there is a new one now Service Status –> Service Status / Add New / Products.

    The notifications get sent when creating a page and/or a post, but not when I create a new status, which is the most important part in my case.

    My question: Is there a way I can enable Subscribe2 to send messages when I make updates to that post type?

    (fyi I have a custom archive-service-status.php , and single-service-status.php)

    I’m afraid that this may not be possible from within existing settings, but if someone would be so kind as to help with enabling the notifications on the new post type. (I’m comfortable navigating the php code).

    Thank you much!

    http://wordpress.org/extend/plugins/subscribe2/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter gkhairallah

    (@gkhairallah)

    Just so I’m not asking the question and not doing any work … 🙂 .. I tried to look up some info. and I found 2 piece of information that may be helpful.
    In my Service Status plugin, there is a “service-status.class.php”, in which I found this code:

    public function init() {
                    $this->register_post_type();
                    $this->register_taxonomy();
            }
    
            public function admin_init() {
                    add_meta_box("service-status-meta", "Status", array( &$this, 'post_status' ), $this->options->post_type, "side", "low");
            }
    
            private function register_post_type() {
                    $supports = array('title','editor');
                    if( $this->options->comments ) {
                            array_push( $supports, 'comments' );
                    }
                    register_post_type( $this->options->post_type,
                            array(
                                    'labels'=> array(
                                            'name'=>__('Service Status'),
                                            'singular_name'=> __('Service Status update'),
                                            'add_new_item'=>__('Add new service status update'),
                                            'edit_item' => __('Edit status update'),
                                    ),
                                    'public'=>true,
                                    'has_archive'=>true,
                                    'rewrite'=>array(
                                            'slug'=>$this->options->slug,
                                            'with_front'=>false,
                                    ),
                                    'exclude_from_search'=>true,
                                    'supports'=> $supports
                            )
                    );
            }

    Also, I looked up some info about integrating subscribe2 into the custom post types, and I found this: http://subscribe2.wordpress.com/2011/02/28/subscribe2-and-custom-post-types/

    and an example of adding code:

    function my_post_types($types) {
    	$types[] = 'my_post_type';
    	return $types;
    }
    
    add_filter('s2_post_types', 'my_post_types');

    At this point though, I’m not sure sure what changes to make in this example, and where to place this code. I figure with these 2 additional details, someone with more php and WP codex knowledge could easily help with this.

    Thanks again,

    @ gkhairallah,

    The custom post type registered by the Service Status plugin seems to be ‘service-status’ so in the latter piece of code you’ve already found you need to change ‘my_post_type’ to ‘service-status’ , like this.

    function my_post_types($types) {
    	$types[] = 'service-status';
    	return $types;
    }
    
    add_filter('s2_post_types', 'my_post_types');

    It should then work if you place this code into a plugin file and activate it on your blog.

    Thread Starter gkhairallah

    (@gkhairallah)

    Excellent @mattyrob. That did it. the only thing that’s still missing, which I suspect you figured was going to be my next question, and that is the Subscribe2 Notification Override section.
    Again, I did my research, and found a standalone plugin you wrote for the AI1EC Subscribe2 plugin, though it looks like this was specifically written for the AI1EC plugin, so when I try to activate the plugin I get this:

    Fatal error: Cannot redeclare my_post_types() (previously declared in /opt/wordpress/wp-content/plugins/service-status/includes/service-status.class.php:132) in /opt/wordpress/wp-content/plugins/AI1EC-Subscribe2/my_post_types.php on line 16

    (which I guess, is to be expected).

    Is there a way to modify that plugin to work with the status-update plugin? or even just modify the PHP code on the Subscribe2 plugin to make that section show up?

    Either method would work, which ever is easier…

    Thanks again for your help. you’re awesome!

    @gkhairallah,

    If you are already running another instance of the same (or very similar) code you’ll get this. It basically because you are using the exact same function name for both instances, so change one from my_post_types() to my_post_types2() or whatever.

    Thread Starter gkhairallah

    (@gkhairallah)

    Excellent. Thank you very much Matt. I actually had to make additional changes to refer to the plugin in question, and also, I realized that the only reason it was happening, was because I wasn’t supposed to implement the original change you suggested along with the AI2EC plugin. So I undid the original one, and modified this one, and now it’s all working.

    Below is the code that now works out-of-the-box with the Service-Status plugin.

    <?php
    /*
    Plugin Name: Service Status Filters & Notification Override
    Plugin URI: http://subscribe2.wordpress.com
    Description: Adds Service Status custom post type and taxonomy to Subscribe2, and enables notification override box on event authoring pages.
    Version: 1.0
    Author: Matthew Robinson / modified by Georges Khairallah
    */
    
    // Allows Subscribe2 to recognize and publish
    // the service status custom post types.
    
    function my_post_types($types) {
            $types[] = 'service-status';
            return $types;
    }
    
    add_filter('s2_post_types','my_post_types');
    
    function my_taxonomy_types($taxonomies) {
            $taxonomies[] = 'products';
            $taxonomiez[] = 'service-status';
            return $taxonomies;
    }
    
    add_filter('s2_taxonomies','my_taxonomy_types');
    
    // Adds the "Subscribe2 Notification Override" button to each
    // systemstatus custom post type authoring page.
    
    function my_meta_types() {
            global $mysubscribe2;
            add_meta_box('subscribe2', 'Subscribe2 Notification Override', array(&$mysubscribe2, 's2_meta_box'), 'service-status','advanced');
    }
    
    add_action('admin_menu', 'my_meta_types');
    
    ?>

    Thanks again for your help,

    Much appreciated!!

    @ Georges,

    That code looks fine but I’ve spotted one typo. In the taxonomy types function on one line you are using the $taxonomies variable but on the next it’s $taxonomiez. The variable name really needs to be the same on both lines.

    Thread Starter gkhairallah

    (@gkhairallah)

    Oops. Thanks for the heads up Matt. I fixed the typo 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Does not publish posts from status update post type’ is closed to new replies.