WordPress.org

Ready to get started?Download WordPress

Forums

WP Boilerplate Shortcode
Not working with WP 3.0.1 (5 posts)

  1. Snow
    Member
    Posted 3 years ago #

    And deleting the plugin was not yet enough to fix things. The "boilerplate" test message I created has attempted to make itself the home page (http://site.com//boilerplates/boilerplate-test/), and there is also a 404 - not found showing for the homepage now. I have to go untangle this now.

  2. Mike Schinkel
    Member
    Plugin Author

    Posted 3 years ago #

    Hi SnowDemon,

    I'm not sure I know what's going on with your system (and I'll try to help you via email anyway) but it was not the plugin. Let's look at the code and you'll see there is absolutely nothing in the plugin that could have caused what happen; it's something else going wrong in your system and my plugin was just the unfortunately bystander:

    WPBoilerplateShortcode::onload();
    
    function the_boilerplate($key,$by='path',$args=array()) {
    	if (in_array($by,array('path','title','id')))
    		$args["by$by"] = $key;
    	echo WPBoilerplateShortcode::boilerplate_shortcode($args);
    }
    
    class WPBoilerplateShortcode {
    	static function onload() {
    		add_action('init', array(__CLASS__,'init_boilerplates'));
    		add_shortcode('boilerplate', array(__CLASS__,'boilerplate_shortcode'));
    	}
    	function init_boilerplates() {
    		if (function_exists('register_post_type')) {
    			register_post_type('boilerplate',
    				array(
    					'singular_label'      => __('Boilerplate'),
    					'label'               => __('Boilerplates'),
    					'exclude_from_search' => true,
    					'publicly_queryable'  => true,
    					'public'              => true,
    					'show_ui'             => true,
    					'query_var'           => 'boilerplates',
    					'rewrite'             => array('slug' => 'boilerplates'),
    					'supports'            => array(
    						'title',
    						'editor',
    						'revisions',
    					),
    				)
    			);
    		}
    	}
    	static function boilerplate_shortcode($args=array()) {
    		$default = array(
    			'bypath' => '',
    			'bytitle' => '',
    			'byid' => '',
    			'id' => '',
    			'class' => 'boilerplate',
    			'title' => '',
    			'showtitle' => false,
    			'titletag' => 'h3',
    		);
    		$args = (object)array_merge($default,$args);
    		if (!empty($args->byid)) {
    			$page = get_page($args->byid);
    		} else if (!empty($args->bypath)) {
    			$page = get_page_by_path($args->bypath,OBJECT,'boilerplate');
    		} else if (!empty($args->bytitle)) { // "bytitle" will only work if this patch is accepted: http://core.trac.wordpress.org/ticket/12743
    			$page = get_page_by_title($args->bytitle,OBJECT,'boilerplate');
    		} else {
    			$page = null;
    		}
    		if (is_null($page))
    			$value = '[ERROR: No "bytitle", "bypath" or "byid" arguments where provided with the boilerplate shortcode' .
    					' or the values provided did not match an existing boilerplate entry.]';
    		else {
    			if (!empty($args->title)){
    				$title = $args->title;
    				$showtitle = true;
    			} else {
    				$title = $page->post_title;
    				$showtitle = $args->showtitle;
    			}
    			$value = (!$showtitle ? '' : "\n<{$args->titletag}>$title</{$args->titletag}>\n");
    			$id = (empty($args->id) ? '' : ' id="' . $args->id . '"');
    			$value =<<<HTML
    <div$id class="$class">$value
    {$page->post_content}
    </div>
    HTML;
    		}
    		return $value;
    	}
    }
  3. Mike Schinkel
    Member
    Plugin Author

    Posted 3 years ago #

    Looks like your problem might be the Redirection plugin and not mine?

    If YES maybe you could vote it down and vote mine back up?

  4. Snow
    Member
    Posted 3 years ago #

    Hi Mike,

    Yes indeed that is the problem. I'm adjusting my ratings now, gladly, and will continue testing your plugin. My rating may go up higher if it can handle my sites needs for single messages included on 30+ pages.

    Thanks very much for your help!

    ~Snow

    P.S. Very sorry I blamed your plugin for the trouble.

  5. Mike Schinkel
    Member
    Plugin Author

    Posted 3 years ago #

    Yes indeed that is the problem. I'm adjusting my ratings now, gladly, and will continue testing your plugin.

    Good deal. You had me wondering because I knew it couldn't have been causing that!

    My rating may go up higher if it can handle my sites needs for single messages included on 30+ pages.

    Ah, so a little friendly extortion, eh? ;-)
    I'll see if I can't help.

    P.S. Very sorry I blamed your plugin for the trouble.

    And no problem, thanks for updating.

    -Mike

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic