'289', 'slug' => '2mb-autocode', 'public_key' => 'pk_e3559cc2e1e944ab0daa1259530a9', 'is_premium' => false, 'has_addons' => false, 'has_paid_plans' => false, 'menu' => array( 'slug' => 'twomb-autocode-settings', 'account' => false, 'contact' => false, 'parent' => array( 'slug' => 'options-general.php', ), ), ) ); } return $twomb_autocode_fs; } // Init Freemius. twomb_autocode_fs(); add_filter('the_content', 'twomb_autocode_modify_content', 8); //Actually add top and bottom content. function twomb_autocode_modify_content($content) { $count = 0; //Do'nt include top content if ##no_top## is set. $content = str_replace('##no_top##', '', $content, $count); $count2 = 0; //Same, but for bottom. $content = str_replace('##no_bottom##', '', $content, $count2); $count3 = 0; //Same, but only for top content on the home page. $content = str_replace('##no_top_home##', '', $content, $count3); $count4 = 0; //Ditto, but for bottom home content. $content = str_replace('##no_bottom_home##', '', $content, $count4); $count5 = 0; //No top content on the single post page. $content = str_replace('##no_top_post##', '', $content, $count5); $count6 = 0; //Same, but for the bottom. $content = str_replace('##no_bottom_post##', '', $content, $count6); $count7 = 0; //We don't want to echo the content twice if they chose an override of placement. if(get_option('2mb_autocode_toptype') == 0) { $content = str_replace('##do_top##', do_shortcode(get_option('2mb_autocode_topstring')), $content, $count7); } else if(get_option('2mb_autocode_toptype') == 1) { ob_start(); eval(get_option('2mb_autocode_topstring')); $topstring = ob_get_contents(); ob_end_clean(); $content = str_replace('##do_top##', do_shortcode($topstring), $content, $count7); } else { $content = str_replace('##do_top##', '
'.get_option('2mb_autocode_topstring').'
', $content, $count7); } $count8 = 0; //Same, but for bottom. if(get_option('2mb_autocode_bottomtype') == 0) { $content = str_replace('##do_bottom##', do_shortcode(get_option('2mb_autocode_bottomstring')), $content, $count8); } else if(get_option('2mb_autocode_bottomtype') == 1) { ob_start(); eval(get_option('2mb_autocode_bottomstring')); $bottomstring = ob_get_contents(); ob_end_clean(); $content = str_replace('##do_bottom##', do_shortcode($bottomstring), $content, $count8); } else { $content = str_replace('##do_bottom##', '
'.get_option('2mb_autocode_bottomstring').'
', $content, $count8); } $count9 = 0; //Check if they had an override to the home pages (for the top content). $content = str_replace('##do_top_home##', '', $content, $count9); $count10 = 0; //Same, but for bottom. $content = str_replace('##do_bottom_home##', '', $content, $count10); $top = 1; $bottom = 1; if($count > 0) { //They told us not to echo the top content anywhere. $top = 0; } if(($count3 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) { //Top content shouldn't be shown on the home page. $top = 0; } if($count5 > 0 && is_single()){ //It shouldn't be shown on the single pages. $top = 0; } if($count2 > 0) { //See count1, but for bottom. $bottom = 0; } if(($count4 > 0 || get_option('2mb_autocode_tophome') == 0) && !is_single()) { //Same, but see count2. $bottom = 0; } if($count6 > 0 && is_single()) { //Ditto, see count 5. $bottom = 0; } if($count9 > 0 && !is_single()) { //They told us to put it on the home page. $top = 1; } if($count10 > 0 && !is_single()) { //Same, but for bottom. $bottom = 1; } global $post; $tophome_force = get_post_meta($post->ID, '2mb_autocode_tophome_force', true); $bottomhome_force = get_post_meta($post->ID, '2mb_autocode_bottomhome_force', true); $top_force = get_post_meta($post->ID, '2mb_autocode_top_force', true); $bottom_force = get_post_meta($post->ID, '2mb_autocode_bottom_force', true); if($tophome_force == '') { $tophome_force = 0; } if($bottomhome_force == '') { $bottomhome_force = 0; } if($top_force == '') { $top_force = 0; } if($bottom_force == '') { $bottom_force = 0; } if($tophome_force == 1 && !is_single()) { //The meta box in the post editor said to put it on the home page. $top = 1; } else if($tophome_force == 2 && !is_single()) { //They told us not to. $top = 0; } if($bottomhome_force == 1 && !is_single()) { //They told us to put the bottom content on the homepage. $bottom = 1; } else if($bottomhome_force == 2 && !is_single()) { //They told us not to. $bottom = 0; } if($top_force == 1 && is_single()) { //Force it on on the post page. $top = 1; } else if($top_force == 2 && is_single()) { //Force it off. $top = 0; } if($bottom_force == 1 && is_single()) { //Force the bottom text on on the post page. $bottom = 1; } if($bottom_force == 2 && is_single()) { //Force it off. $bottom = 0; } if($count7 > 0) { //We already echoed the top content. $top = 0; } if($count8 > 0) { //Yep, we echoed the bottom. $bottom = 0; } if($top == 1) { //Finally, we need to display the content! if(get_option('2mb_autocode_toptype') == 1) { //php ob_start(); eval(get_option('2mb_autocode_topstring')); $string = ob_get_contents(); ob_end_clean(); $content = do_shortcode($string).$content; } else if(get_option('2mb_autocode_toptype') == 2) { //Pre-formatted text. $content = '
'.get_option('2mb_autocode_topstring').'
'.$content; } else { //html. $content = do_shortcode(get_option('2mb_autocode_topstring')).$content; } } if($bottom == 1) { //We need to echo the bottom content. if(get_option('2mb_autocode_bottomtype') == 1) { //php ob_start(); eval(get_option('2mb_autocode_bottomstring')); $string = ob_get_contents(); ob_end_clean(); $content = $content.do_shortcode($string); } else if(get_option('2mb_autocode_bottomtype') == 2) { //pre-formatted text. $content = $content.'
'.get_option('2mb_autocode_bottomstring').'
'; } else { //html $content = $content.do_shortcode(get_option('2mb_autocode_bottomstring')); } } return $content; } add_action('the_content', 'twomb_autocode_do_php', 0); //Parse php in the post with [php] ... [/php] tags. function twomb_autocode_do_php($content) { $content = preg_replace_callback('/\[php\]((.|\n)+)\[\/php\]/', 'twomb_autocode_exec_php', $content); //I know, weird regex. return $content; } function twomb_autocode_exec_php($matches) { ob_start(); eval($matches[1]); $output = ob_get_contents(); ob_end_clean(); return $output; } add_action('admin_menu', 'twomb_autocode_init_admin_menu'); //Make our sub-menu. function twomb_autocode_init_admin_menu() { add_options_page('Autocode Options', 'Autocode', 'manage_options', 'twomb-autocode-settings', 'twomb_autocode_options'); } function twomb_autocode_options() { if(!current_user_can( 'manage_options')) { wp_die( 'You do not have rights to access this page.'); } ?>

Wait just a second.

Do you like this plugin? Does it make your life just a little bit easier -- we hope! If it does, please consider donating to help our plugin effort along. Any amount helps. We'll love you forever ;-)

Amount: $ USD

Also please consider visiting our website to stay up to date on 2MB Solutions news, plugins, offers, and more. Click here to visit.

Documentation

This plugin is rather simple, but to make it as easy as possible to use this plugin, we will include some documentation here:


Remember, feedback is most welcome! Visit our homepage to suggest a feature, a new plugin, and more.

2) { return 0; } else { return (int)$data; } } function twomb_autocode_tophome_sanitize($data) { if($data == NULL) { return 0; } else { if($data == 'true') { return 1; } else { return 0; } } } function twomb_autocode_bottomtype_sanitize($data) { if((int)$data < 0 || (int)$data > 2) { return 0; } else { return (int)$data; } } function twomb_autocode_bottomstring_sanitize($data) { return wp_kses_post($data); } function twomb_autocode_bottomhome_sanitize($data) { if($data == NULL) { return 0; } else { if($data == 'true') { return 1; } else { return 0; } } } function twomb_autocode_topstring_print() { ?> > Html > php > Preformatted text
Note: When using php, you must echo any required output, and not include any php tags. Also, when using preformatted text, shortcodes will not work. > Yes > Html > php > Preformatted text
Note: When using php, you must echo any required output, and not include any php tags. Also, when using preformatted text, shortcodes will not work. > Yes

Enter your settings below, then click save to save your changes.

ID, '2mb_autocode_tophome_force', true); if($value == '') { $value = 0; } ?>

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.
':'>'); ?> Do what is set in the autocode settings.
':'>'); ?> Force the top text to appear on this post for the home page.
':'>'); ?> Force the top text to not show on the home page for this post.

ID, '2mb_autocode_bottomhome_force', true); if($value == '') { $value = 0; } ?>

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.
':'>'); ?> Do what is set in the autocode settings.
':'>'); ?> Force the bottom text to appear on this post for the home page.
':'>'); ?> Force the bottom text to not show on the home page for this post.

ID, '2mb_autocode_top_force', true); if($value == '') { $value = 0; } ?>

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.
':'>'); ?> Do what is set in the autocode settings.
':'>'); ?> Force the top text to appear on this post.
':'>'); ?> Force the top text to not show on this post.

ID, '2mb_autocode_bottom_force', true); if($value == '') { $value = 0; } ?>

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.
':'>'); ?> Do what is set in the autocode settings.
':'>'); ?> Force the bottom text to appear on this post.
':'>'); ?> Force the bottom text to not show on this post.

2) { $tophome = 0; } if($bottomhome < 0 || $bottomhome > 2) { $bottomhome = 0; } if($top < 0 || $top > 2) { $top = 0; } if($bottom < 0 || $bottom > 2) { $bottom = 0; } update_post_meta($post_id, '2mb_autocode_tophome_force', $tophome); update_post_meta($post_id, '2mb_autocode_bottomhome_force', $bottomhome); update_post_meta($post_id, '2mb_autocode_top_force', $top); update_post_meta($post_id, '2mb_autocode_bottom_force', $bottom); } ?>