Changeset 1208943
- Timestamp:
- 07/29/2015 11:44:45 AM (11 years ago)
- Location:
- 2mb-autocode
- Files:
-
- 3 added
- 4 edited
- 10 copied
-
tags/1.1 (added)
-
tags/1.1.1 (added)
-
tags/1.1.1/2mb-autocode.php (copied) (copied from 2mb-autocode/trunk/2mb-autocode.php)
-
tags/1.1.1/index.php (copied) (copied from 2mb-autocode/trunk/index.php)
-
tags/1.1.1/readme.txt (copied) (copied from 2mb-autocode/trunk/readme.txt)
-
tags/1.1.2 (added)
-
tags/1.1.2/2mb-autocode.php (copied) (copied from 2mb-autocode/trunk/2mb-autocode.php) (2 diffs)
-
tags/1.1.2/index.php (copied) (copied from 2mb-autocode/trunk/index.php)
-
tags/1.1.2/readme.txt (copied) (copied from 2mb-autocode/trunk/readme.txt) (4 diffs)
-
tags/1.1/2mb-autocode.php (copied) (copied from 2mb-autocode/trunk/2mb-autocode.php)
-
tags/1.1/index.php (copied) (copied from 2mb-autocode/trunk/index.php)
-
tags/1.1/readme.txt (copied) (copied from 2mb-autocode/trunk/readme.txt)
-
tags/1.2 (copied) (copied from 2mb-autocode/trunk)
-
tags/1.2/2mb-autocode.php (modified) (10 diffs)
-
tags/1.2/readme.txt (modified) (7 diffs)
-
trunk/2mb-autocode.php (modified) (10 diffs)
-
trunk/readme.txt (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
2mb-autocode/tags/1.1.2/2mb-autocode.php
r988120 r1208943 6 6 Plugin Name: 2MB Autocode 7 7 Plugin URI: http://2mb.solutions/plugins/autocode 8 Version: 1.1. 18 Version: 1.1.2 9 9 License: Gpl v2 or later 10 10 */ … … 115 115 } 116 116 117 add_action('the_content', ' do_php', 0);118 function do_php($content) {119 $content = preg_replace_callback('/\[php\]((.|\n)+)\[\/php\]/', ' exec_php', $content);117 add_action('the_content', 'twomb_autocode_do_php', 0); 118 function twomb_autocode_do_php($content) { 119 $content = preg_replace_callback('/\[php\]((.|\n)+)\[\/php\]/', 'twomb_autocode_exec_php', $content); 120 120 return $content; 121 121 } 122 122 123 function exec_php($matches) {123 function twomb_autocode_exec_php($matches) { 124 124 ob_start(); 125 125 eval($matches[1]); -
2mb-autocode/tags/1.1.2/readme.txt
r988120 r1208943 5 5 Requires at least: 2.7.0 6 6 Tested up to: 4.0 7 Stable tag: 1.1. 17 Stable tag: 1.1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 52 52 Simply put ##do_top_home## or ##do_bottom_home## anywhere in the post. 53 53 54 = My blog is broken and just shows the white screen of death after upgrading to 1.1 or 1.1.1! help! = 55 56 Do not worry, the fix is a simple one: 57 58 1. Delete or move the inline php plugin folder on your server, and the blog should be accessible again. 59 1. Now upgrade to 2mb autocode version 1.1.2, which fixes this particular issue. 60 1. 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 54 62 == Screenshots == 55 63 … … 57 65 58 66 == 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 ;-). 59 70 60 71 = 1.1.1 = … … 74 85 == Upgrade Notice == 75 86 87 = 1.1.2 = 88 If 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 = 95 If 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 76 97 = 1.1 = 77 98 If 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 6 6 Plugin Name: 2MB Autocode 7 7 Plugin URI: http://2mb.solutions/plugins/autocode 8 Version: 1. 1.28 Version: 1.2 9 9 License: Gpl v2 or later 10 10 */ … … 12 12 13 13 add_filter('the_content', 'twomb_autocode_modify_content', 9999); 14 15 14 function twomb_autocode_modify_content($content) { 16 15 $count = 0; … … 31 30 } 32 31 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); 34 37 } 35 38 else { … … 41 44 } 42 45 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); 44 51 } 45 52 else { … … 55 62 $top = 0; 56 63 } 57 if(($count3 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {64 if(($count3 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) { 58 65 $top = 0; 59 66 } … … 64 71 $bottom = 0; 65 72 } 66 if(($count4 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {73 if(($count4 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) { 67 74 $bottom = 0; 68 75 } … … 81 88 if($count10 > 0 && !is_single()) { 82 89 $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; 83 131 } 84 132 if($top == 1) { … … 130 178 131 179 add_action('admin_menu', 'twomb_autocode_init_admin_menu'); 132 133 180 function twomb_autocode_init_admin_menu() { 134 181 add_options_page('Autocode Options', 'Autocode', 'manage_options', 'twomb-autocode-settings', 'twomb_autocode_options'); … … 182 229 183 230 add_action('admin_init', 'twomb_autocode_init_settings'); 184 185 231 function twomb_autocode_init_settings() { 186 232 add_settings_section('twomb-autocode-settings', 'Autocode Options', 'twomb_autocode_print_section', 'twomb-autocode-settings'); … … 317 363 } 318 364 365 add_action('add_meta_boxes', 'twomb_autocode_add_meta_box'); 366 function twomb_autocode_add_meta_box() { 367 add_meta_box('2mb_autocode_options', 'Autocode Options', 'twomb_autocode_post_options', 'post'); 368 } 369 370 function 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> 378 Should 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> 393 Should 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> 408 Should 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> 423 Should 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 434 add_action( 'save_post', 'twomb_autocode_save_meta_box_data' ); 435 function 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 319 480 ?> -
2mb-autocode/tags/1.2/readme.txt
r1049212 r1208943 4 4 Tags: autocode, code placement, automatic, php, html, preformatted text, top, bottom, modify posts 5 5 Requires at least: 2.7.0 6 Tested up to: 4. 17 Stable tag: 1. 1.26 Tested up to: 4.2.3 7 Stable tag: 1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 16 16 17 17 For more on 2MB, please visit (http://2mb.solutions/). 18 19 Note that all development now takes place at [github](http://github.com/2mb-solutions/autocode/). 18 20 19 21 == Installation == … … 34 36 = How do I remove the text from a specific post! HELP! = 35 37 38 There 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 36 40 Simply 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. 37 41 … … 50 54 = How do I make the text go on the homepage without setting the checkbox! = 51 55 56 There 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 52 58 Simply put ##do_top_home## or ##do_bottom_home## anywhere in the post. 53 59 … … 60 66 1. 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 67 68 = Why isn't any development taking place at wordpress.org? = 69 70 We 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 62 72 == Screenshots == 63 73 … … 65 75 66 76 == 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? 67 82 68 83 = 1.1.2 = … … 91 106 == Upgrade Notice == 92 107 108 = 1.2 = 109 110 You 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 93 112 = 1.1.2 = 94 113 If you use inline php to do your php inside posts: -
2mb-autocode/trunk/2mb-autocode.php
r988138 r1208943 6 6 Plugin Name: 2MB Autocode 7 7 Plugin URI: http://2mb.solutions/plugins/autocode 8 Version: 1. 1.28 Version: 1.2 9 9 License: Gpl v2 or later 10 10 */ … … 12 12 13 13 add_filter('the_content', 'twomb_autocode_modify_content', 9999); 14 15 14 function twomb_autocode_modify_content($content) { 16 15 $count = 0; … … 31 30 } 32 31 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); 34 37 } 35 38 else { … … 41 44 } 42 45 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); 44 51 } 45 52 else { … … 55 62 $top = 0; 56 63 } 57 if(($count3 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {64 if(($count3 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) { 58 65 $top = 0; 59 66 } … … 64 71 $bottom = 0; 65 72 } 66 if(($count4 > 0 && !is_single()) || get_option('2mb_autocode_tophome') == 0) {73 if(($count4 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) { 67 74 $bottom = 0; 68 75 } … … 81 88 if($count10 > 0 && !is_single()) { 82 89 $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; 83 131 } 84 132 if($top == 1) { … … 130 178 131 179 add_action('admin_menu', 'twomb_autocode_init_admin_menu'); 132 133 180 function twomb_autocode_init_admin_menu() { 134 181 add_options_page('Autocode Options', 'Autocode', 'manage_options', 'twomb-autocode-settings', 'twomb_autocode_options'); … … 182 229 183 230 add_action('admin_init', 'twomb_autocode_init_settings'); 184 185 231 function twomb_autocode_init_settings() { 186 232 add_settings_section('twomb-autocode-settings', 'Autocode Options', 'twomb_autocode_print_section', 'twomb-autocode-settings'); … … 317 363 } 318 364 365 add_action('add_meta_boxes', 'twomb_autocode_add_meta_box'); 366 function twomb_autocode_add_meta_box() { 367 add_meta_box('2mb_autocode_options', 'Autocode Options', 'twomb_autocode_post_options', 'post'); 368 } 369 370 function 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> 378 Should 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> 393 Should 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> 408 Should 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> 423 Should 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 434 add_action( 'save_post', 'twomb_autocode_save_meta_box_data' ); 435 function 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 319 480 ?> -
2mb-autocode/trunk/readme.txt
r1049212 r1208943 4 4 Tags: autocode, code placement, automatic, php, html, preformatted text, top, bottom, modify posts 5 5 Requires at least: 2.7.0 6 Tested up to: 4. 17 Stable tag: 1. 1.26 Tested up to: 4.2.3 7 Stable tag: 1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 16 16 17 17 For more on 2MB, please visit (http://2mb.solutions/). 18 19 Note that all development now takes place at [github](http://github.com/2mb-solutions/autocode/). 18 20 19 21 == Installation == … … 34 36 = How do I remove the text from a specific post! HELP! = 35 37 38 There 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 36 40 Simply 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. 37 41 … … 50 54 = How do I make the text go on the homepage without setting the checkbox! = 51 55 56 There 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 52 58 Simply put ##do_top_home## or ##do_bottom_home## anywhere in the post. 53 59 … … 60 66 1. 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 67 68 = Why isn't any development taking place at wordpress.org? = 69 70 We 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 62 72 == Screenshots == 63 73 … … 65 75 66 76 == 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? 67 82 68 83 = 1.1.2 = … … 91 106 == Upgrade Notice == 92 107 108 = 1.2 = 109 110 You 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 93 112 = 1.1.2 = 94 113 If you use inline php to do your php inside posts:
Note: See TracChangeset
for help on using the changeset viewer.