Aug 122011
 
WordPress Plugin Name: Global Content Blocks
Plugin URL:http://wordpress.org/plugins/global-content-blocks/

Plugin Author: Dave Liske
WordPress profile: Dave Liske
Plugin version: 2.1.5
Last updated: December 13, 2015 (7 months ago)
Tested up to (WP version): WP 4.4.4
Downloaded: 101,184
Rating: 5 (out of 5)

Description


Global Content Blocks lets you create your own shortcodes to insert reusable code snippets, PHP or HTML including forms, opt-in boxes, iframes, Adsense code, etc, into pages and posts as well as widgets and directly into php content. You can insert them directly using shortcodes or via a button in the TinyMCE visual editor toolbar. You can also insert the entire content of the Content Block instead of the shortcode or use other shortcodes within the Content Block. You can also modify the output of the Content Block via a hook.

It is ideal for inserting reusable objects into your content or to prevent the WordPress editor from stripping out your code or otherwise changing your formatting. The shortcodes are masked as images to allow easy manipulation and non-html tags contamination.

You can also use your own variables, WordPress global variables and other shortcodes within Content Blocks, modify the output, use shortcodes in themes and widgets, nest shorcodes and a whole lot more. See http://micuisine.com/content-block-plugins/category/gcb-advanced-usage/ for more information.

The plugin includes an Import/Export fuction to copy content blocks from one WordPress site to another.

Further information and screenshots are available on the plugin homepage at http://micuisine.com/content-block-plugins/global-content-blocks/.

As featured on ManageWP Blog (http://managewp.com/global-content-blocks) and Spanky Media (http://spankymedia.com.au/using-wordpress-global-content-blocks-to-promote-your-content/).

If you have any feedback, issues or suggestions for improvements please leave a comment on the plugin homepage and if you like the plugin please give it a rating at http://wordpress.org/extend/plugins/global-content-blocks 🙂



FAQ


How big a content block can I add?

The content block will hold up to 64,000 characters.

Can I create content blocks with PHP code?

Yes, just copy the PHP as normal into a content block without the <?php, <?, ?> tags and insert the block into your content as normal.

Can I create content blocks using a visual editor?

Yes, the Settings page where the content blocks are created includes the standard WordPress visual/HTML editor.

How do I use a shortcode within a content block?

Simply add the shortcode within a block as normal, for example [gallery] to add a WordPress gallery.

Can I use content blocks outside of posts and pages?

Yes, just wrap it in the PHP function <?php echo gcb(x);?> where x is the content block ID. You can also use the longer form <?php do_shortcode("[contentblock id=x]");?>

Why do the contentblock shortcodes display instead of my content when I link to one of my posts or pages in Facebook?

If you look at the source code for your page you'll likely find something like this: < ! -- This site is optimized with the Yoast SEO plugin v3.0.3 - https: //yoast.com/wordpress/plugins/seo/ -- > < meta name="description" content="[contentblock id=hmn_yanagibas_oct] [contentblock id=17 img=gcb.png]"/ > What happens is that Facebook scrapes the meta description (or an og:description if you have that set up instead) and loads it as the description for their link. That's probably what you're seeing happen, especially since this is the only place the shortcodes appear when viewing the page source. This is a known issue with the Yoast SEO plugin, as described here: https://github.com/Yoast/wordpress-seo/issues/2846 Looking at their changelog, it appears the fix has not yet been implemented. If you're so inclined, the solution is also listed on the above linked page. I haven't tried it myself, so I can offer no guarantees. But this issue is definitely reproducable with the current version of the Yoast plugin installed.

Is it possible to modify the output of inserted content blocks?

Yes, you can add the filter 'gcb_block_output' to modify output by adding a PHP script to functions.php, for example:
add_filter('gcb_block_output', 'alter_block_output');
function alter_block_output($value) {
//process the output here, e.g., convert text to lowercase
$new_value = strtolower($value);
return "Processed output: ".$new_value;
}

Can I use variables?

Yes, You can use variables within the content block that will be replaced when the block is displayed. For example, if you create a content block, say id=1 with: My name is %%name%%
by using the shortcode [contentblock id=1 name="John Doe"] when displayed it will appear as My name is John Doe.

Can I use WordPress global variables?

Yes, WordPress global variables can be used within content blocks, for example, global $user_login;
global $user_email;
echo "$user_login, you email is: $user_email";
would output the username and email of the current logged in user, e.g., John, your email is john@youremail.com.

Will I lose my content blocks if I change the theme or upgrade WordPress?

No, the blocks are added to the WordPress database, so are independent of the theme and unaffected by WordPress upgrades.

Can it be completely uninstalled?

Yes, there is an option to delete the database table if you want to completely remove the plugin.

Can I copy any content blocks I've created to another WordPress site?

Yes, an Import/Export function is included. Just Export form one site, install the plugin on the other site and import.



Screenshots:


  1. global-content-blocks screenshot 1

    The Settings page

  2. global-content-blocks screenshot 2

    Adding a new Content Block

  3. global-content-blocks screenshot 3

    Inserting a Content Block using the toolbar button

  4. global-content-blocks screenshot 4

    Inserting a Content Block using the shortcode



Other notes:




Latest Change log entry:


  • Changed auto paragraphs in Tiny MCE
  • Updated for WP 4.4.


Tags:


admin, adsense, code, Code Snippet, content block, editor, form, Formatting, forms, global, global variables, html, iframe, insert, javascript, modify output, pages, paypal, php, posts, raw html, reusable, reuse, shortcode, shortcodes, snippet, TinyMCE, variables

+ Jason's Comments

Useful for re-using template components in similar posts with editing all in one place. Works well with titled expandable content boxes, see Collapse-O-Matic

NOTE: August 2016 – This plugin has been removed from the WordPress repository for security reasons.

An alternative plugin is Reusable Text Blocks.
Another alternative is using a page builder such as from SiteOrigin or Divi by Elegant themes and saving the re-usable sections to the library.