Plugin Directory

Changeset 1208943


Ignore:
Timestamp:
07/29/2015 11:44:45 AM (11 years ago)
Author:
lilmike
Message:

Version 1.2

Location:
2mb-autocode
Files:
3 added
4 edited
10 copied

Legend:

Unmodified
Added
Removed
  • 2mb-autocode/tags/1.1.2/2mb-autocode.php

    r988120 r1208943  
    66Plugin Name: 2MB Autocode
    77Plugin URI: http://2mb.solutions/plugins/autocode
    8 Version: 1.1.1
     8Version: 1.1.2
    99License: Gpl v2 or later
    1010*/
     
    115115}
    116116
    117 add_action('the_content', 'do_php', 0);
    118 function do_php($content) {
    119     $content = preg_replace_callback('/\[php\]((.|\n)+)\[\/php\]/', 'exec_php', $content);
     117add_action('the_content', 'twomb_autocode_do_php', 0);
     118function twomb_autocode_do_php($content) {
     119    $content = preg_replace_callback('/\[php\]((.|\n)+)\[\/php\]/', 'twomb_autocode_exec_php', $content);
    120120    return $content;
    121121}
    122122
    123 function exec_php($matches) {
     123function twomb_autocode_exec_php($matches) {
    124124    ob_start();
    125125    eval($matches[1]);
  • 2mb-autocode/tags/1.1.2/readme.txt

    r988120 r1208943  
    55Requires at least: 2.7.0
    66Tested up to: 4.0
    7 Stable tag: 1.1.1
     7Stable tag: 1.1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5252Simply put  ##do_top_home## or ##do_bottom_home## anywhere in the post.
    5353
     54= My blog is broken and just shows the white screen of death after upgrading to 1.1 or 1.1.1! help! =
     55
     56Do not worry, the fix is a simple one:
     57
     581. Delete or move the inline php plugin folder on your server, and the blog should be accessible again.
     591. Now upgrade to 2mb autocode version 1.1.2, which fixes this particular issue.
     601. Optional but highly recommended: Replace all [exec] or <exec> tags with [php] tags to allow 2mb autocode to do the php for you, and you will have no need for inline php.
     61
    5462== Screenshots ==
    5563
     
    5765
    5866== Changelog ==
     67
     68= 1.1.2 =
     69*Very important! If you were using inline php to put php on your blog before, please upgrade to this version or uninstall inline php before upgrading to 2mb autocode 1.1. There was a problem that caused the two plugins to conflict, which has now been solved. *** NOTE *** if your blog is not accessible due to the conflict, do the following: Delete the inline php folder from your server, and all should be well. We're sorry for any inconvenience -- sometimes even plugin developers can screw up ;-).
    5970
    6071= 1.1.1 =
     
    7485== Upgrade Notice ==
    7586
     87= 1.1.2 =
     88If you use inline php to do your php inside posts:
     89
     90*You don't need to anymore, as this plugin will handle it for you.
     91*Please update to this version or uninstall the inline php plugin because the two plugins conflict. This has now been fixed.
     92*If your blog is totally broken and you cannot access the admin panel to remove the plugin inline php, then simply delete the inline php plugin folder from your server, and the problem will be solved. Sorry for any inconvenience (even coding ninjas are durps sometimes too, ;-))
     93
     94= 1.1.1 =
     95If you didn't know how to use the plugin... this update is for you. This update adds documentation inside the plugin, as well as adds ##do_top_home## and ##do_bottom_home## to force displaying the text on a per-post basis on the homepage, no matter what the checkbox says in the options pannel.
     96
    7697= 1.1 =
    7798If you were using php at the top or bottom of a post, please upgrade to this version as this fixes a possibility that the php code would not run or the php may have echoed to the wrong part of the screen. In addition if you want to run php code in your posts without having to add it to every post, then you may like this release. Also, if you wish to turn off the placing of text on a per post basis for the home and/or single post pages, this update is for you.
  • 2mb-autocode/tags/1.2/2mb-autocode.php

    r988138 r1208943  
    66Plugin Name: 2MB Autocode
    77Plugin URI: http://2mb.solutions/plugins/autocode
    8 Version: 1.1.2
     8Version: 1.2
    99License: Gpl v2 or later
    1010*/
     
    1212
    1313add_filter('the_content', 'twomb_autocode_modify_content', 9999);
    14 
    1514function twomb_autocode_modify_content($content) {
    1615    $count = 0;
     
    3130    }
    3231    else if(get_option('2mb_autocode_toptype') == 1) {
    33         $content = str_replace('##do_top##', do_shortcode(exec(get_option('2mb_autocode_topstring'))), $content, $count7);
     32                ob_start();
     33                eval(get_option('2mb_autocode_topstring'));
     34                $topstring = ob_get_contents();
     35                ob_end_clean();
     36        $content = str_replace('##do_top##', do_shortcode($topstring), $content, $count7);
    3437    }
    3538    else {
     
    4144    }
    4245    else if(get_option('2mb_autocode_bottomtype') == 1) {
    43         $content = str_replace('##do_bottom##', do_shortcode(exec(get_option('2mb_autocode_bottomstring'))), $content, $count8);
     46                ob_start();
     47                eval(get_option('2mb_autocode_bottomstring'));
     48                $bottomstring = ob_get_contents();
     49                ob_end_clean();
     50        $content = str_replace('##do_bottom##', do_shortcode($bottomstring), $content, $count8);
    4451    }
    4552    else {
     
    5562        $top = 0;
    5663    }
    57     if(($count3 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {
     64    if(($count3 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) {
    5865        $top = 0;
    5966    }
     
    6471        $bottom = 0;
    6572    }
    66     if(($count4 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {
     73    if(($count4 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) {
    6774        $bottom = 0;
    6875    }
     
    8188    if($count10  > 0 && !is_single()) {
    8289        $bottom = 1;
     90    }
     91    global $post;
     92    $tophome_force = get_post_meta($post->ID, '2mb_autocode_tophome_force', true);
     93    $bottomhome_force = get_post_meta($post->ID, '2mb_autocode_bottomhome_force', true);
     94    $top_force = get_post_meta($post->ID, '2mb_autocode_top_force', true);
     95    $bottom_force = get_post_meta($post->ID, '2mb_autocode_bottom_force', true);
     96    if($tophome_force == '') {
     97        $tophome_force = 0;
     98    }
     99    if($bottomhome_force == '') {
     100        $bottomhome_force = 0;
     101    }
     102    if($top_force == '') {
     103        $top_force = 0;
     104    }
     105    if($bottom_force == '') {
     106        $bottom_force = 0;
     107    }
     108    if($tophome_force == 1 && !is_single()) {
     109        $top = 1;
     110    }
     111    else if($tophome_force == 2 && !is_single()) {
     112        $top = 0;
     113    }
     114    if($bottomhome_force == 1 && !is_single()) {
     115        $bottom = 1;
     116    }
     117    else if($bottomhome_force == 2 && !is_single()) {
     118        $bottom = 0;
     119    }
     120    if($top_force == 1 && is_single()) {
     121        $top = 1;
     122    }
     123    else if($top_force == 2 && is_single()) {
     124        $top = 0;
     125    }
     126    if($bottom_force == 1 && is_single()) {
     127        $bottom = 1;
     128    }
     129    if($bottom_force == 2 && is_single()) {
     130        $bottom = 0;
    83131    }
    84132    if($top == 1) {
     
    130178
    131179add_action('admin_menu', 'twomb_autocode_init_admin_menu');
    132 
    133180function twomb_autocode_init_admin_menu() {
    134181    add_options_page('Autocode Options', 'Autocode', 'manage_options', 'twomb-autocode-settings', 'twomb_autocode_options');
     
    182229
    183230add_action('admin_init', 'twomb_autocode_init_settings');
    184 
    185231function twomb_autocode_init_settings() {
    186232    add_settings_section('twomb-autocode-settings', 'Autocode Options', 'twomb_autocode_print_section', 'twomb-autocode-settings');
     
    317363}
    318364
     365add_action('add_meta_boxes', 'twomb_autocode_add_meta_box');
     366function twomb_autocode_add_meta_box() {
     367    add_meta_box('2mb_autocode_options', 'Autocode Options', 'twomb_autocode_post_options', 'post');
     368}
     369
     370function twomb_autocode_post_options ($post) {
     371    wp_nonce_field( 'twomb_autocode_save_meta_box_data', 'twomb_autocode_meta_box_nonce' );
     372    $value = get_post_meta($post->ID, '2mb_autocode_tophome_force', true);
     373    if($value == '') {
     374        $value = 0;
     375    }
     376    ?>
     377<p>
     378Should the top text be prepended to that on the home page? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     379<br>
     380<input type="radio" name="2mb_autocode_tophome_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     381<br>
     382<input type="radio" name="2mb_autocode_tophome_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the top text to appear on this post for the home page.
     383<br>
     384<input type="radio" name="2mb_autocode_tophome_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the top text to not show on the home page for this post.
     385</p>
     386<?php
     387    $value = get_post_meta($post->ID, '2mb_autocode_bottomhome_force', true);
     388    if($value == '') {
     389        $value = 0;
     390    }
     391    ?>
     392<p>
     393Should the bottom text be appended to that on the home page? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     394<br>
     395<input type="radio" name="2mb_autocode_bottomhome_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     396<br>
     397<input type="radio" name="2mb_autocode_bottomhome_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the bottom text to appear on this post for the home page.
     398<br>
     399<input type="radio" name="2mb_autocode_bottomhome_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the bottom text to not show on the home page for this post.
     400</p>
     401<?php
     402    $value = get_post_meta($post->ID, '2mb_autocode_top_force', true);
     403    if($value == '') {
     404        $value = 0;
     405    }
     406    ?>
     407<p>
     408Should the top text be prepended to this post? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     409<br>
     410<input type="radio" name="2mb_autocode_top_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     411<br>
     412<input type="radio" name="2mb_autocode_top_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the top text to appear on this post.
     413<br>
     414<input type="radio" name="2mb_autocode_top_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the top text to not show on this post.
     415</p>
     416<?php
     417    $value = get_post_meta($post->ID, '2mb_autocode_bottom_force', true);
     418    if($value == '') {
     419        $value = 0;
     420    }
     421    ?>
     422<p>
     423Should the bottom text be appended to this post? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     424<br>
     425<input type="radio" name="2mb_autocode_bottom_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     426<br>
     427<input type="radio" name="2mb_autocode_bottom_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the bottom text to appear on this post.
     428<br>
     429<input type="radio" name="2mb_autocode_bottom_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the bottom text to not show on this post.
     430</p>
     431<?php
     432}
     433
     434add_action( 'save_post', 'twomb_autocode_save_meta_box_data' );
     435function twomb_autocode_save_meta_box_data( $post_id ) {
     436    if ( !isset( $_POST['twomb_autocode_meta_box_nonce'] ) ) {
     437        return;
     438    }
     439    if ( !wp_verify_nonce( $_POST['twomb_autocode_meta_box_nonce'], 'twomb_autocode_save_meta_box_data' ) ) {
     440        return;
     441    }
     442    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     443        return;
     444    }
     445    if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
     446        if ( !current_user_can( 'edit_page', $post_id ) ) {
     447            return;
     448        }
     449    }
     450    else {
     451        if ( !current_user_can( 'edit_post', $post_id ) ) {
     452            return;
     453        }
     454    }
     455    if(!isset($_POST['2mb_autocode_tophome_force']) || !isset($_POST['2mb_autocode_bottomhome_force']) || !isset($_POST['2mb_autocode_top_force']) || !isset($_POST['2mb_autocode_bottom_force'])) {
     456        return;
     457    }
     458    $tophome = (int)$_POST['2mb_autocode_tophome_force'];
     459    $bottomhome = (int)$_POST['2mb_autocode_bottomhome_force'];
     460    $top = (int)$_POST['2mb_autocode_top_force'];
     461    $bottom = (int)$_POST['2mb_autocode_bottom_force'];
     462    if($tophome < 0 || $tophome > 2) {
     463        $tophome = 0;
     464    }
     465    if($bottomhome < 0 || $bottomhome > 2) {
     466        $bottomhome = 0;
     467    }
     468    if($top < 0 || $top > 2) {
     469        $top = 0;
     470    }
     471    if($bottom < 0 || $bottom > 2) {
     472        $bottom = 0;
     473    }
     474    update_post_meta($post_id, '2mb_autocode_tophome_force', $tophome);
     475    update_post_meta($post_id, '2mb_autocode_bottomhome_force', $bottomhome);
     476    update_post_meta($post_id, '2mb_autocode_top_force', $top);
     477    update_post_meta($post_id, '2mb_autocode_bottom_force', $bottom);
     478}
     479
    319480?>
  • 2mb-autocode/tags/1.2/readme.txt

    r1049212 r1208943  
    44Tags: autocode, code placement, automatic, php, html, preformatted text, top, bottom, modify posts
    55Requires at least: 2.7.0
    6 Tested up to: 4.1
    7 Stable tag: 1.1.2
     6Tested up to: 4.2.3
     7Stable tag: 1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1616
    1717For more on 2MB, please visit (http://2mb.solutions/).
     18
     19Note that all development now takes place at [github](http://github.com/2mb-solutions/autocode/).
    1820
    1921== Installation ==
     
    3436= How do I remove the text from a specific post! HELP! =
    3537
     38There are now options on each post's edit page to force remove, force add, or do neither to the text on the top and bottom of either home or post pages. The text below is still valid, however the settings just mentioned will override the tags below if set to anything except do nothing.
     39
    3640Simply put ##no_top## or ##no_bottom## anywhere in the post, and it will remove those tags, and not put the text on bottom or top depending on which tag(s) you entered. In addition, if you put ##no_top_home##, ##no_bottom_home##, ##no_top_post##, or ##no_bottom_post##, it will remove the text from either the top or bottom of either the post page or the homepage, no matter what is set in the settings.
    3741
     
    5054= How do I make the text go on the homepage without setting the checkbox! =
    5155
     56There is now an options panel on each post, so you can force text on the home page, force text to not be on the homepage, or defer to the main settings. The text below is still valid, but when set to anything except do nothing, the options on the post editor will override these tags.
     57
    5258Simply put  ##do_top_home## or ##do_bottom_home## anywhere in the post.
    5359
     
    60661. Optional but highly recommended: Replace all [exec] or <exec> tags with [php] tags to allow 2mb autocode to do the php for you, and you will have no need for inline php.
    6167
     68= Why isn't any development taking place at wordpress.org? =
     69
     70We have now moved our official development version to [github](http://github.com/2mb-solutions/autocode/). Feel free to test the code if you wish, and/or open issues over there although any issues or problems reported on the wordpress.org forums will also be dealt with.
     71
    6272== Screenshots ==
    6373
     
    6575
    6676== Changelog ==
     77
     78= 1.2 =
     79
     80*Added an options panel on the post editor so you can now set custom post overrides without having to insert tags such as ##do_post_home##.
     81*Fixed a nasty bug in which text on each post's single page was suppressed when the home checkbox was unchecked. Whoops?
    6782
    6883= 1.1.2 =
     
    91106== Upgrade Notice ==
    92107
     108= 1.2 =
     109
     110You can now override text placement on a per-post basis in the editor, instead of having to use special tags. Also if your text was not showing on each post when the home checkbox was unchecked, this fixes that issue.
     111
    93112= 1.1.2 =
    94113If you use inline php to do your php inside posts:
  • 2mb-autocode/trunk/2mb-autocode.php

    r988138 r1208943  
    66Plugin Name: 2MB Autocode
    77Plugin URI: http://2mb.solutions/plugins/autocode
    8 Version: 1.1.2
     8Version: 1.2
    99License: Gpl v2 or later
    1010*/
     
    1212
    1313add_filter('the_content', 'twomb_autocode_modify_content', 9999);
    14 
    1514function twomb_autocode_modify_content($content) {
    1615    $count = 0;
     
    3130    }
    3231    else if(get_option('2mb_autocode_toptype') == 1) {
    33         $content = str_replace('##do_top##', do_shortcode(exec(get_option('2mb_autocode_topstring'))), $content, $count7);
     32                ob_start();
     33                eval(get_option('2mb_autocode_topstring'));
     34                $topstring = ob_get_contents();
     35                ob_end_clean();
     36        $content = str_replace('##do_top##', do_shortcode($topstring), $content, $count7);
    3437    }
    3538    else {
     
    4144    }
    4245    else if(get_option('2mb_autocode_bottomtype') == 1) {
    43         $content = str_replace('##do_bottom##', do_shortcode(exec(get_option('2mb_autocode_bottomstring'))), $content, $count8);
     46                ob_start();
     47                eval(get_option('2mb_autocode_bottomstring'));
     48                $bottomstring = ob_get_contents();
     49                ob_end_clean();
     50        $content = str_replace('##do_bottom##', do_shortcode($bottomstring), $content, $count8);
    4451    }
    4552    else {
     
    5562        $top = 0;
    5663    }
    57     if(($count3 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {
     64    if(($count3 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) {
    5865        $top = 0;
    5966    }
     
    6471        $bottom = 0;
    6572    }
    66     if(($count4 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {
     73    if(($count4 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) {
    6774        $bottom = 0;
    6875    }
     
    8188    if($count10  > 0 && !is_single()) {
    8289        $bottom = 1;
     90    }
     91    global $post;
     92    $tophome_force = get_post_meta($post->ID, '2mb_autocode_tophome_force', true);
     93    $bottomhome_force = get_post_meta($post->ID, '2mb_autocode_bottomhome_force', true);
     94    $top_force = get_post_meta($post->ID, '2mb_autocode_top_force', true);
     95    $bottom_force = get_post_meta($post->ID, '2mb_autocode_bottom_force', true);
     96    if($tophome_force == '') {
     97        $tophome_force = 0;
     98    }
     99    if($bottomhome_force == '') {
     100        $bottomhome_force = 0;
     101    }
     102    if($top_force == '') {
     103        $top_force = 0;
     104    }
     105    if($bottom_force == '') {
     106        $bottom_force = 0;
     107    }
     108    if($tophome_force == 1 && !is_single()) {
     109        $top = 1;
     110    }
     111    else if($tophome_force == 2 && !is_single()) {
     112        $top = 0;
     113    }
     114    if($bottomhome_force == 1 && !is_single()) {
     115        $bottom = 1;
     116    }
     117    else if($bottomhome_force == 2 && !is_single()) {
     118        $bottom = 0;
     119    }
     120    if($top_force == 1 && is_single()) {
     121        $top = 1;
     122    }
     123    else if($top_force == 2 && is_single()) {
     124        $top = 0;
     125    }
     126    if($bottom_force == 1 && is_single()) {
     127        $bottom = 1;
     128    }
     129    if($bottom_force == 2 && is_single()) {
     130        $bottom = 0;
    83131    }
    84132    if($top == 1) {
     
    130178
    131179add_action('admin_menu', 'twomb_autocode_init_admin_menu');
    132 
    133180function twomb_autocode_init_admin_menu() {
    134181    add_options_page('Autocode Options', 'Autocode', 'manage_options', 'twomb-autocode-settings', 'twomb_autocode_options');
     
    182229
    183230add_action('admin_init', 'twomb_autocode_init_settings');
    184 
    185231function twomb_autocode_init_settings() {
    186232    add_settings_section('twomb-autocode-settings', 'Autocode Options', 'twomb_autocode_print_section', 'twomb-autocode-settings');
     
    317363}
    318364
     365add_action('add_meta_boxes', 'twomb_autocode_add_meta_box');
     366function twomb_autocode_add_meta_box() {
     367    add_meta_box('2mb_autocode_options', 'Autocode Options', 'twomb_autocode_post_options', 'post');
     368}
     369
     370function twomb_autocode_post_options ($post) {
     371    wp_nonce_field( 'twomb_autocode_save_meta_box_data', 'twomb_autocode_meta_box_nonce' );
     372    $value = get_post_meta($post->ID, '2mb_autocode_tophome_force', true);
     373    if($value == '') {
     374        $value = 0;
     375    }
     376    ?>
     377<p>
     378Should the top text be prepended to that on the home page? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     379<br>
     380<input type="radio" name="2mb_autocode_tophome_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     381<br>
     382<input type="radio" name="2mb_autocode_tophome_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the top text to appear on this post for the home page.
     383<br>
     384<input type="radio" name="2mb_autocode_tophome_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the top text to not show on the home page for this post.
     385</p>
     386<?php
     387    $value = get_post_meta($post->ID, '2mb_autocode_bottomhome_force', true);
     388    if($value == '') {
     389        $value = 0;
     390    }
     391    ?>
     392<p>
     393Should the bottom text be appended to that on the home page? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     394<br>
     395<input type="radio" name="2mb_autocode_bottomhome_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     396<br>
     397<input type="radio" name="2mb_autocode_bottomhome_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the bottom text to appear on this post for the home page.
     398<br>
     399<input type="radio" name="2mb_autocode_bottomhome_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the bottom text to not show on the home page for this post.
     400</p>
     401<?php
     402    $value = get_post_meta($post->ID, '2mb_autocode_top_force', true);
     403    if($value == '') {
     404        $value = 0;
     405    }
     406    ?>
     407<p>
     408Should the top text be prepended to this post? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     409<br>
     410<input type="radio" name="2mb_autocode_top_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     411<br>
     412<input type="radio" name="2mb_autocode_top_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the top text to appear on this post.
     413<br>
     414<input type="radio" name="2mb_autocode_top_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the top text to not show on this post.
     415</p>
     416<?php
     417    $value = get_post_meta($post->ID, '2mb_autocode_bottom_force', true);
     418    if($value == '') {
     419        $value = 0;
     420    }
     421    ?>
     422<p>
     423Should the bottom text be appended to this post? Note: The first option means that it will not be set specifically on this post, it will simply follow what is set in the options page. The other options will change the option only for this post.
     424<br>
     425<input type="radio" name="2mb_autocode_bottom_force" value="0"<?php echo(($value == 0)?' checked="checked">':'>'); ?> Do what is set in the autocode settings.
     426<br>
     427<input type="radio" name="2mb_autocode_bottom_force" value="1"<?php echo(($value == 1)?' checked="checked">':'>'); ?> Force the bottom text to appear on this post.
     428<br>
     429<input type="radio" name="2mb_autocode_bottom_force" value="2"<?php echo(($value == 2)?' checked="checked">':'>'); ?> Force the bottom text to not show on this post.
     430</p>
     431<?php
     432}
     433
     434add_action( 'save_post', 'twomb_autocode_save_meta_box_data' );
     435function twomb_autocode_save_meta_box_data( $post_id ) {
     436    if ( !isset( $_POST['twomb_autocode_meta_box_nonce'] ) ) {
     437        return;
     438    }
     439    if ( !wp_verify_nonce( $_POST['twomb_autocode_meta_box_nonce'], 'twomb_autocode_save_meta_box_data' ) ) {
     440        return;
     441    }
     442    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     443        return;
     444    }
     445    if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
     446        if ( !current_user_can( 'edit_page', $post_id ) ) {
     447            return;
     448        }
     449    }
     450    else {
     451        if ( !current_user_can( 'edit_post', $post_id ) ) {
     452            return;
     453        }
     454    }
     455    if(!isset($_POST['2mb_autocode_tophome_force']) || !isset($_POST['2mb_autocode_bottomhome_force']) || !isset($_POST['2mb_autocode_top_force']) || !isset($_POST['2mb_autocode_bottom_force'])) {
     456        return;
     457    }
     458    $tophome = (int)$_POST['2mb_autocode_tophome_force'];
     459    $bottomhome = (int)$_POST['2mb_autocode_bottomhome_force'];
     460    $top = (int)$_POST['2mb_autocode_top_force'];
     461    $bottom = (int)$_POST['2mb_autocode_bottom_force'];
     462    if($tophome < 0 || $tophome > 2) {
     463        $tophome = 0;
     464    }
     465    if($bottomhome < 0 || $bottomhome > 2) {
     466        $bottomhome = 0;
     467    }
     468    if($top < 0 || $top > 2) {
     469        $top = 0;
     470    }
     471    if($bottom < 0 || $bottom > 2) {
     472        $bottom = 0;
     473    }
     474    update_post_meta($post_id, '2mb_autocode_tophome_force', $tophome);
     475    update_post_meta($post_id, '2mb_autocode_bottomhome_force', $bottomhome);
     476    update_post_meta($post_id, '2mb_autocode_top_force', $top);
     477    update_post_meta($post_id, '2mb_autocode_bottom_force', $bottom);
     478}
     479
    319480?>
  • 2mb-autocode/trunk/readme.txt

    r1049212 r1208943  
    44Tags: autocode, code placement, automatic, php, html, preformatted text, top, bottom, modify posts
    55Requires at least: 2.7.0
    6 Tested up to: 4.1
    7 Stable tag: 1.1.2
     6Tested up to: 4.2.3
     7Stable tag: 1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1616
    1717For more on 2MB, please visit (http://2mb.solutions/).
     18
     19Note that all development now takes place at [github](http://github.com/2mb-solutions/autocode/).
    1820
    1921== Installation ==
     
    3436= How do I remove the text from a specific post! HELP! =
    3537
     38There are now options on each post's edit page to force remove, force add, or do neither to the text on the top and bottom of either home or post pages. The text below is still valid, however the settings just mentioned will override the tags below if set to anything except do nothing.
     39
    3640Simply put ##no_top## or ##no_bottom## anywhere in the post, and it will remove those tags, and not put the text on bottom or top depending on which tag(s) you entered. In addition, if you put ##no_top_home##, ##no_bottom_home##, ##no_top_post##, or ##no_bottom_post##, it will remove the text from either the top or bottom of either the post page or the homepage, no matter what is set in the settings.
    3741
     
    5054= How do I make the text go on the homepage without setting the checkbox! =
    5155
     56There is now an options panel on each post, so you can force text on the home page, force text to not be on the homepage, or defer to the main settings. The text below is still valid, but when set to anything except do nothing, the options on the post editor will override these tags.
     57
    5258Simply put  ##do_top_home## or ##do_bottom_home## anywhere in the post.
    5359
     
    60661. Optional but highly recommended: Replace all [exec] or <exec> tags with [php] tags to allow 2mb autocode to do the php for you, and you will have no need for inline php.
    6167
     68= Why isn't any development taking place at wordpress.org? =
     69
     70We have now moved our official development version to [github](http://github.com/2mb-solutions/autocode/). Feel free to test the code if you wish, and/or open issues over there although any issues or problems reported on the wordpress.org forums will also be dealt with.
     71
    6272== Screenshots ==
    6373
     
    6575
    6676== Changelog ==
     77
     78= 1.2 =
     79
     80*Added an options panel on the post editor so you can now set custom post overrides without having to insert tags such as ##do_post_home##.
     81*Fixed a nasty bug in which text on each post's single page was suppressed when the home checkbox was unchecked. Whoops?
    6782
    6883= 1.1.2 =
     
    91106== Upgrade Notice ==
    92107
     108= 1.2 =
     109
     110You can now override text placement on a per-post basis in the editor, instead of having to use special tags. Also if your text was not showing on each post when the home checkbox was unchecked, this fixes that issue.
     111
    93112= 1.1.2 =
    94113If you use inline php to do your php inside posts:
Note: See TracChangeset for help on using the changeset viewer.