Plugin Directory

Changeset 987913


Ignore:
Timestamp:
09/12/2014 05:27:48 AM (12 years ago)
Author:
lilmike
Message:

Added a way to override for only the home or post pages, and a way to put the code in a different place on the page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2mb-autocode/trunk/2mb-autocode.php

    r984821 r987913  
    55Description: This plugin allows you to place predetermined text, php, or shortcodes at the top and/or bottom of posts.
    66Plugin Name: 2MB Autocode
    7 Plugin URI: http://2mb.solutions/autocode
    8 Version: 1.0
     7Plugin URI: http://2mb.solutions/plugins/autocode
     8Version: 1.1
    99License: Gpl v2 or later
    1010*/
     
    1818    $count2 = 0;
    1919    $content = str_replace('##no_bottom##', '', $content, $count2);
    20     if((is_single() || get_option('2mb_autocode_tophome') == 1) && $count == 0) {
     20    $count3 = 0;
     21    $content = str_replace('##no_top_home##', '', $content, $count3);
     22    $count4 = 0;
     23    $content = str_replace('##no_bottom_home##', '', $content, $count4);
     24    $count5 = 0;
     25    $content = str_replace('##no_top_post##', '', $content, $count5);
     26    $count6 = 0;
     27    $content = str_replace('##no_bottom_post##', '', $content, $count6);
     28    $count7 = 0;
     29    if(get_option('2mb_autocode_toptype') == 0) {
     30        $content = str_replace('##do_top##', do_shortcode(get_option('2mb_autocode_topstring')), $content, $count7);
     31    }
     32    else if(get_option('2mb_autocode_toptype') == 1) {
     33        $content = str_replace('##do_top##', do_shortcode(exec(get_option('2mb_autocode_topstring'))), $content, $count7);
     34    }
     35    else {
     36        $content = str_replace('##do_top##', '<pre>'.get_option('2mb_autocode_topstring').'</pre>', $content, $count7);
     37    }
     38    $count8 = 0;
     39    if(get_option('2mb_autocode_bottomtype') == 0) {
     40        $content = str_replace('##do_bottom##', do_shortcode(get_option('2mb_autocode_bottomstring')), $content, $count8);
     41    }
     42    else if(get_option('2mb_autocode_bottomtype') == 1) {
     43        $content = str_replace('##do_bottom##', do_shortcode(exec(get_option('2mb_autocode_bottomstring'))), $content, $count8);
     44    }
     45    else {
     46        $content = str_replace('##do_bottom##', '<pre>'.get_option('2mb_autocode_bottomstring').'</pre>', $content, $count8);
     47    }
     48    $top = 1;
     49    $bottom = 1;
     50    if($count > 0) {
     51        $top = 0;
     52    }
     53    if($count3 > 0 && !is_single()) {
     54        $top = 0;
     55    }
     56    if($count5 > 0 && is_single()){
     57        $top = 0;
     58    }
     59    if($count2 > 0) {
     60        $bottom = 0;
     61    }
     62    if($count4 > 0 && !is_single()) {
     63        $bottom = 0;
     64    }
     65    if($count6 > 0 && is_single()){
     66        $bottom = 0;
     67    }
     68    if($count7 > 0) {
     69        $top = 0;
     70    }
     71    if($count8 > 0) {
     72        $bottom = 0;
     73    }
     74    if($top == 1) {
    2175        if(get_option('2mb_autocode_toptype') == 1) {
    2276            $content = do_shortcode(exec(get_option('2mb_autocode_topstring'))).$content;
     
    2983        }
    3084    }
    31     if((is_single() || get_option('2mb_autocode_bottomhome') == 1) && $count2 == 0) {
     85    if($bottom == 1) {
    3286        if(get_option('2mb_autocode_bottomtype') == 1) {
    3387            $content = $content.do_shortcode(exec(get_option('2mb_autocode_bottomstring')));
Note: See TracChangeset for help on using the changeset viewer.