Code Insert Manager (Q2W3 Inc Manager)

This plugin was made to easily add html, css, php or javascript code to public WordPress pages.

Contents:

UPDATE FROM ver 1.x to 2.x NOTE:
Following page selectors have been removed: All Posts, All Pages, Category Pages and Tag Pages.
Inserts that used them will not work. But don’t worry, just recreate «Insert» and «Exclude» rules and they will work again!

Installation

  1. Check minimal system requirements: WordPress 2.8.0, PHP 5.1.0.
  2. Download plugin.
  3. Unzip and upload `q2w3-inc-manager` folder to the `/wp-content/plugins/` directory.
  4. Activate the plugin through the ‘Plugins’ menu in WordPress.

Uninstallation

  1. On the ‘Plugins’ menu in WordPress click ‘Deactivate’ plugin link.
  2. You will be redirected to the page with two options:
    • ‘Deactivate plugin’ — for simple plugin deactivation. Use it for temporary plugin deactivation if you plan to use plugin in future.
    • ‘Deactivate plugin and delete all settings from database’ — for complete plugin deactivation. All data associated with the plugin will be deleted from database.
Plugin deactivate options
Plugin deactivate options

Working with plugin
First of all go to the plugin setting page.
To begin creation of your Include click ‘Create new’ button. Include options window will appear.

Include options window
Include options window

Let’s see what are the meanings of all those options:

  • Description. A shot description of your code. Something like ‘My banner’ or ‘Google Analitics’.
  • Status. There are two options:
    • Active. Include code will be shown.
    • Disabled. Include code will not be shown.
  • Location. Here you can select area of the page where your code will appear. Possible locations are:
    1. Header (between <head></head> tags). Suitable for placing meta tags like Google Webmaster Tools ID, css or javascript code. Do not place here html code for visual output like <div>Hello</div>.
    2. Footer (bottom of the page). Suitable for placing any type of code. For expample this is a right place for Google Analitics code.
    3. Before page content (before WP loop). Suitable for any types of advertisement.
    4. After page content (after WP loop). Suitable for any types of advertisement.
    5. Before post content. Suitable for any types of advertisement.
    6. After post excerpt (since version 2.0.0).
    7. After post content. Suitable for any types of advertisement.
    8. Widget. Suitable for inserting advertisement blocks to the sidebar. Widget must be activated on the Appearance->Widgets page.
      • There is a sub option for Widget location — Widget title. This title is only for public pages. If no title provided, only widget include code will be displayed.
    9. Manual. This option allows you to place php function directly in your theme file.
    10. Shortcode. Insert code inside page or post content.

      Code Insert Locations
      Code Insert Locations
  • Priority. This field determines display order of the includes placed in the same location. Field value must be integer. Includes with equal priorities are sorted by creation time. Newer includes will be displayed after older. If you set priority to 0 or leave it empty, after saving include priority value will become equal to 100. This is done to create include with priority ‘always first’ and ‘always last’. To make include always first set priority to 1 and make sure that there are no other includes with this priority in the same location. To make include always last set priority higher than 100 (for example 1000). Now all new includes with undefined priority will be placed between ‘always first’ and ‘always last’.
  • Include on. Here you can select pages where your code CAN be shown. To select multiple pages or deselect page hold CTRL key. WordPress pages, posts pages, categories pages and tag pages can be selected one by one. Also there are several special page selectors:
    • All. That means all public pages.
    • Front page. Whether it is posts or a Page. Sub pages also belong to the front page. To exclude subpages select `Paged pages` in Exclude on section.
    • WP pages. These are WordPress Pages, not any generic webpage from your blog.
    • Posts pages. All post pages.
    • Date pages. These are all date-based archive pages (i.e. a monthly, yearly, daily or time-based archive).
    • Category pages. All Category archive pages.
    • Tag pages. All Tag archive pages.
    • Author pages. All author pages.
    • Attachment pages. All attachment pages.
    • Paged pages. All pages being displayed as «paged». This refers to an archive or the main page being split up over several pages. Only second and subsequent pages are considered «paged». This does not refer to a Post or Page whose content has been divided into pages using the nextpage QuickTag.
    • Search page. Any search result page.
    • Preview page. Single post page displayed in Draft mode.
    • Page 404. Paged displayed when ‘HTTP 404 Page not found’ error happens.
  • Exclude on. Here you can select pages where your code CANNOT be shown. Multiple select can be done by holding CTRL key.
  • Hide from admin. Since version 2.0 this option upgraded to Hide from user. Now you can specify user groups to hide code from.
  • Code. Html, css or javascript code. Inclusion of PHP code supported since version 1.1.0. PHP code must begins with `php open tag` (<?php). Examples:
<?php /* php open tag is required */ echo 'WP variable: '; print_r($GLOBALS['wp']); /* php close tag is not required */

 

<h1>Hello!</h1><?php echo 'PHP!' ?><h2>Bye!</h2>
  • Sub option Align (since version 1.1.0). Allows you to set horizontal align of the included code. Useful for aligning Google AdSense blocks.

A few words about settings page interface.
You can select table columns which will be displayed and can change number of table rows per page. To do this go to Screen options menu.

Screen options
Screen options

Also if Include options window is taking to much place you can minimize it by clicking on the window top bar (see screen shot above).

Frequently Asked Questions

  1. How many Includes may I create?

    The number of Includes is unlimited.

  2. What is ‘Widget title’ option?

    This option allows you to specify widget title for public WordPress pages. It will be displayed like Categories or Tags widget titles.
    If you leave this option blanc, widget will be displayed without title.

  3. I have set priority to 0 or left it blanc, but after saving it equals 100. Why?

    This is done to help you create Include with priority ‘always first’ and ‘always last’. To make Include always first set priority to 1 and make sure that there are no other includes with this priority in the same location. To make include always last set priority higher than 100 (for example 1000). Now all new includes with undefined priority will be placed between ‘always first’ and ‘always last’.

  4. Why Widget and Manual Includes priority is always 100 and I can’t change it?

    Widget and Manual Includes don’t use priority number for sorting. Don’t worry about it.

  5. In wich order sorted Includes with equal priorities?

    Equal priority Includes are sorted by creation time. Newer includes will be displayed after older.

Changelog

  • 2.3.0
    Added ability to insert shortcodes in comments. Option must be enabled in Code Insert Manager -> Settings page
  • 2.2.0
    Added support for Custom Post Type Archive pages
    Fixed small bug with Opera multiple select
  • 2.1.2
    Fixed conflict with Find and replace plugin (Guys, why are you creating new user instance each time?!?).
  • 2.1.1
    Added German translation
  • 2.1.0
    Post Formats are now available for page filters
    To admin page added search form and capability to filter table by status (Active/Disabled)
  • 2.0.1
    Plugin renamed to Code Insert Manager
    Added support for custom post types (support for each post type must be enabled on plugin settings page)
    Added support for custom taxonomies (support for each taxonomy must be enabled on plugin settings page)
    Added new insert location — After post excerpt
    Hide from admin option is upgraded to Hide from user
    Admin menu entry moved to top level
  • 1.3.1
    Added French translation.
  • 1.3.0
    Added new location — shortcode
  • 1.2.4
    Fixed php evaluation error in Manual include mode
    Plugin was successfully tested in WordPress 3.0
  • 1.2.3
    Improved page detection on themes with modified loop.
  • 1.2.2
    Fixed high memory usage on blogs with large number of posts/categories (more than 1000)
  • 1.2.1
    Fixed broken links (in plugin settings page) when WordPress installed in a subdirectory.
  • 1.2.0
    Fixed errors in WordPress MU.
  • 1.1.0
    New. Includes with PHP code now supported.
    New. Align option added.
  • 1.0.1
    Fixed ‘Create New’ button malfunction in Opera and Firefox.
    Fixed ‘Parse error: syntax error, unexpected T_PROTECTED in /htdocs/wp-content/plugins/q2w3-inc-manager/q2w3-table/q2w3_table.php on line 736’.
  • 1.0
    First public release.

Other Q2W3 plugins:

161 ответ к “Code Insert Manager (Q2W3 Inc Manager)”

Hi Max,

I just wanted to say thanks for providing this great plugin! I spent a couple hours looking for a simple method to add my google remarketing code to my Morrow’s Nut House site. Thanks to the efficient design of your plugin and your clear support documentation I was able to complete this work in about fifteen minutes.

Keep up the great work,
John

This is a great plugin! seriously! I have just one question, I need to create a new location like the manual option, but that serves to insert multiple codes in the same location, as with the location in header, footer … If I use the manual option, I have to include a line for each new code you want displayed in the same location. Is there any way to do this? In my opinion, is what would be missing the plugin to be PERFECT.

Hi. I absolutely LOVE this plugin, if only I could get it to work. :( It seems very user friendly for someone who doesn’t know much code at all. But I couldn’t get either a shortcode or widget to work. First I tried copying and pasting css code that works because I’ve tested it…into the place for the code…creating a shortcode. Then I went to insert shortcode and nothing appeared on the screen, other than the shortcode parameters themselves. Then I tried to create a widget. I saw the widget in my widget options. I placed them where I wanted them. But on the screen there was nothing…no errors or anything. Just nothing. Please help—I think I’m doing something simple wrong since this is working for everyone else but I have tried lots of changes and cannot get this to work!! Thank you!!

Hello!
Check your shortcode syntax: shortcode parameters must be separated with ONE space. Also there might be a conflict with other plugins…

About widget. What pages you have selected for displaying the widget? All pages or a specific page?

Hi. Thanks so much for trying to help me!! I’m not sure what you mean. Do you mean the code that I am inserting? Or the actual shortcode text?

The shortcode text is:

[include id="1" title="city box short code"]

I was trying to insert: (cut and pasted below exactly as inserted into shortcode box in your plugin):

For larger commercial installations, we travel all over Florida.We also ocassionally travel to Lakeland and even Tampa for larger commercial chain accounts.

 

Can you please help?! I guess there might be a conflict with another plug in. :(

Oh, man, what a terrible bummer. :( :(

The problem is that I like some of the plug ins a lot, and some took quite a while for a non-techie gal to figure out. Do you see any likely suspects?

Otherwise I guess I’ll have to uninstall…which really sucks because I cannot figure out how to insert code otherwise. :( :( I thought I had found the holy grail. I still think it’s a great plug in it’s just that some of those other plugins took forever to configure and I want to leave them, like WidgetKit (slider), wunderground (weather), tiny mce (weather), seo yoast, and even the shortcode program…:(

Well anyway thank you for taking a look and let me know if you see anything that jumps out otherwise I guess I’ll have to keep looking but you keep doing a great job creating plugins!

Hi.

This is a great plugin except for one thing. If like me you are using the classipress theme there does not seem to be the option to post in the categories section. You can only seem to post in the actual advert.?

Look at Code Insert -> Settings page.
There you can enable/disable custom post types and custom taxonomies. You need to enable Expand option for Categories taxonomy, then you’ll be able to select individual categories for your inserts.

thanks for recent RSS fix Max. i have couple of feature requests to make this plugin the best!
1. for «Insert on Pages» you have already «Categories», the conditional is_category(), is possible to do «Posts in Category», the conditional in_category() too? this would allow single posts in a selected Category to display code output.
2. what about rotating ad code? i know i can include php code to rotate, but with ability to rotate adcode, it would really make this plugin number 1 of all available ad or code injector plugins at WordPress.
what do you think?

Hi,

My theme has custom posts called events. I would like to insert the code on category pages for the custom posts. How can I do this? A feature request for next release would be for the plugin to identify custom posts/categories and add them to the available places to place the code.

Thanks for your help!!

Hello!

Ability to insert code in custom post types is already exists.
You need to enable post type on Code Insert -> Settings page.
Check expand option if you want to insert code for specific post.

Hi Max,

I’m pretty new to WP code and PHP overall. I’m just wondering if you can use post variables directly right after post ends.

For example: If I use «code insert» after post and I need to get post title and URL. Is there WP variables to use? I want to add facebook share so I need to add post URL to It.

Thanks

Hello!

You can access post data.

To view all available data insert this code:

<?php var_dump($GLOBALS['post']) ?>

Print post title:

<?php echo $GLOBALS['post']->post_title; ?>

Print post permalink:

<?php echo get_permalink($GLOBALS['post']->ID); ?>

Hi!

Replace function wp_load() in q2w3_table_func file by this function:

public static function wp_load() {
	
  $wp_root = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
		
  if (file_exists($wp_root.'/wp-load.php')) {
	
    return $wp_root.'/wp-load.php';
	
  } else {
		
    exit('Can not find wp-load.php!');
		
  }
			
}

This version doesn’t need wp-content dir to find wp-load.php!

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *


Срок проверки reCAPTCHA истек. Перезагрузите страницу.