Plugin Directory

Changeset 1260100


Ignore:
Timestamp:
10/06/2015 02:39:02 AM (10 years ago)
Author:
boyevul
Message:

fixed an error when excluding posts based on user levels

Location:
my-optional-modules/trunk
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • my-optional-modules/trunk/class.myoptionalmodules-modules.php

    r1255257 r1260100  
    1818    function __construct() {
    1919        if ( get_option ( 'myoptionalmodules_javascripttofooter' ) ) {
    20             add_action ( 'wp_enqueue_scripts' , array ( $this , 'remove' ) );
     20            add_action ( 'wp_enqueue_scripts' , array ( $this , 'move_to_footer' ) );
    2121            add_action ( 'wp_footer' , 'wp_enqueue_scripts' , 5 );
    2222            add_action ( 'wp_footer' , 'wp_print_head_scripts' , 5 );
     
    112112   
    113113    /**
    114      * Extras -> Javascript-to-footer
    115      * Remove enqueued scripts from wp_head
     114     Extras
     115        Javascript-to-Footer
     116        Attempts to move all .js to the footer
     117        Theme must have wp_footer() for this to work.
    116118     */
    117     function remove() {
    118         remove_action ( 'wp_head' , 'wp_print_head_scripts' , 9 );
    119         remove_action ( 'wp_head' , 'wp_enqueue_scripts' , 1 );
    120     }
    121 
     119    function move_to_footer(){
     120        remove_action( 'wp_head', 'wp_print_head_scripts', 9 );
     121        remove_action( 'wp_head', 'wp_enqueue_scripts', 1 );
     122    }
     123   
    122124    /**
    123      * Extras -> Enable Exclude Posts
    124      * Exclude posts from the loop based on several
    125      * parameters (set in options).
    126      */
    127     function exclude( $query ) {
     125     Extras
     126        Enable Exclude Posts
     127        Allows the admin to exclude posts from various
     128        parts of the blog based on different parameters.
     129     */
     130    function exclude( $query ){
    128131        $count = 0;
    129132        ++$count;
    130         if ( 1 == $count ) {
     133        if( 1 == $count ){
    131134            include( 'function.exclude.php' );
    132135        }
    133136    }
    134137   
    135     // Twitter Field for User Profiles
     138   
     139   
     140   
     141   
     142    /**
     143     Adds a Twitter handle field to the user profile
     144     when Enable Meta Tags is enabled.
     145     */
    136146    function twitter( $profile_fields ){
    137147        $profile_fields['twitter_personal'] = 'Twitter handle';
    138148        return $profile_fields;
    139149    }
    140 
    141     // Meta Tags (og:/Twitter)
    142     function meta() {
    143 
    144         global $post, $wp;
    145 
    146         $author    = null;
    147 
    148         // OG:
     150   
     151    /**
     152     Enable
     153        Enable Meta Tags
     154        Enables meta tags for posts, in the form
     155        of OG:tags.
     156     */
     157    function meta(){
     158
     159        global $post;
     160        global $wp;
     161
     162        $author         = null;
    149163        $id             = null;
    150164        $title          = null;
     
    164178        $num            = null;
    165179
    166         if( is_single() || is_page() )
     180        if( is_single() || is_page() ){
    167181            $id = $post->ID;
    168 
    169         if( is_single() || is_page() || is_author() )
     182        }
     183
     184        if( is_single() || is_page() || is_author() ){
    170185            $author = $post->post_author;
     186        }
    171187
    172188        $og_type = 'image';
    173189   
    174190        if( is_single() || is_page() ) {
    175             $type  = 'article';
    176             $title = sanitize_text_field ( str_replace ( '\'' , '' , get_post_field ( 'post_title' , $id ) ) );
    177             $image = wp_get_attachment_image_src ( get_post_thumbnail_id ( $id ) , 'single-post-thumbnail' );
    178             $image = $image[0];
    179             $url      = get_permalink( $id );
    180             $site     = get_bloginfo( 'name' );
    181             $excerpt  = strip_tags ( esc_html ( preg_replace ( '/\s\s+/i' , '' , get_the_excerpt ( ) ) ) );
     191            $type    = 'article';
     192            $title   = sanitize_text_field ( str_replace ( '\'' , '' , get_post_field ( 'post_title' , $id ) ) );
     193            $image   = wp_get_attachment_image_src ( get_post_thumbnail_id ( $id ) , 'single-post-thumbnail' );
     194            $image   = $image[0];
     195            $url     = get_permalink( $id );
     196            $site    = get_bloginfo( 'name' );
     197            $excerpt = strip_tags ( esc_html ( preg_replace ( '/\s\s+/i' , '' , get_the_excerpt ( ) ) ) );
    182198        } else {
    183             $title    = get_bloginfo ( 'name' );
    184             $url      = esc_url ( home_url ( '/' ) );
    185             $type     = 'website';
     199            $title = get_bloginfo ( 'name' );
     200            $url   = esc_url ( home_url ( '/' ) );
     201            $type  = 'website';
    186202        }
    187203
     
    215231        if ( $modified_time ):  echo "\n<meta property='article:modified_time' content='{$modified_time}' />";   endif;
    216232        if ( $modified_time ):  echo "\n<meta property='og:updated_time' content='{$modified_time}' />";         endif;
    217         if ($posttags):
     233       
     234        if( $posttags ){
    218235            echo "\n<meta property='article:tag' content='";
    219236              foreach( $posttags as $tag ):
     
    224241              endforeach;
    225242            echo "' />";
    226         endif;
    227 
     243        }
     244
     245        $author         = null;
    228246        $id             = null;
    229247        $title          = null;
     
    246264        $card        = null;
    247265        $attribution = null;
    248        
    249266        if( is_single() || is_page() ) {
    250267            $card        = 'summary';
    251268            $attribution = get_the_author_meta ( 'twitter_personal' , $author );
    252269            $attribution = sanitize_text_field ( str_replace ( array ( '@' , '\'' ) , '' , $attribution ) );
    253 
    254270            if( $attribution ) {
    255271                $card        = sanitize_text_field ( $card );
    256272                $attribution = sanitize_text_field ( $attribution );
    257 
    258273                if( $card )        echo "\n<meta name='twitter:card' content='{$card}'>";
    259274                if( $attribution ) echo "\n<meta name='twitter:creator' content='@{$attribution}'>";
    260 
    261275            }
    262 
    263276            $card         = null;
    264277            $attribution  = null;
    265 
    266278        }
    267279       
    268280        // Noindex/Noarchive archives/404s/search results to avoid duplicate content
    269281        if(
    270             is_search() ||
    271             is_404() ||
     282            is_search()  ||
     283            is_404()     ||
    272284            is_archive()
    273285        ){
     
    277289        echo "\n\n";
    278290       
    279         $author = null;
    280 
    281291    }
    282292
    283293    // Horizontal Gallery Shortcode
    284     function horizontal_gallery_shortcode() {
    285 
    286         add_shortcode ( 'gallery' , array ( $this , 'shortcode_output' ) );
    287 
     294    function horizontal_gallery_shortcode(){
     295        add_shortcode( 'gallery', array( $this, 'shortcode_output' ));
    288296    }
    289297
  • my-optional-modules/trunk/function.exclude.php

    r1255257 r1260100  
    33 * FUNCTION(ality) Exclude Posts
    44 *
    5  * File last update: 10.1.9
     5 * File last update: 10.2
    66 *
    77 * Alter the query to remove posts based on many parameters
     
    308308if ( intval ( $chck_users ) || intval ( $chck_cats ) || intval ( $chck_tags ) ):
    309309    add_filter( 'the_content', 'myoptionalmodules_destroy_content_view', 20 );
    310     function myoptionalmodules_destroy_content_view( $content ) {
    311         if( is_single() ):
    312             $content = '<div class="mom-unauthorized-content">You do not have permission to view this content.</div>';
    313             return do_shortcode ( $content );
    314         endif;
    315     }
    316 endif;
     310    if(!function_exists('myoptionalmodules_destroy_content_view')){
     311        function myoptionalmodules_destroy_content_view( $content ) {
     312            if( is_single() ):
     313                $content = '<div class="mom-unauthorized-content">You do not have permission to view this content.</div>';
     314                return do_shortcode ( $content );
     315            endif;
     316        }
     317    }
     318endif;
  • my-optional-modules/trunk/plugin.php

    r1255257 r1260100  
    44Plugin URI:
    55Description: Optional modules and additions for Wordpress.
    6 Version: 10.1.9
     6Version: 10.2
    77Author: boyevul
    88Author URI:
     
    3939*/
    4040
     41/**
     42 * Initial Plugin Setup
     43 */
    4144define ( 'MyOptionalModules', true );
     45
     46/**
     47 * We need pluggable for certain plugin actions
     48 */
     49require_once ( ABSPATH . 'wp-includes/pluggable.php' );
    4250
    4351/**
     
    5260}
    5361
    54 require_once ( ABSPATH . 'wp-includes/pluggable.php' );
    55 include ( 'function.category-ids.php' );
    56 
    57 if ( get_option ( 'myoptionalmodules_exclude' ) ) { include ( 'function.exclude-categories.php' ); }
    58 if ( get_option ( 'myoptionalmodules_recentpostswidget' ) ) { include ( 'function.recent-posts.php'       ); }
     62/**
     63 * Include plugin files
     64 */
     65if ( get_option ( 'myoptionalmodules_recentpostswidget' ) ) {
     66    include ( 'function.recent-posts.php' );
     67}
    5968if ( get_option ( 'myoptionalmodules_pluginshortcodes' ) ) {
    60     if( get_option ( 'myoptionalmodules_miniloopamount' ) && get_option ( 'myoptionalmodules_miniloopstyle' ) && get_option ( 'myoptionalmodules_miniloopmeta' ) ) {
     69    if (
     70        get_option ( 'myoptionalmodules_miniloopamount' ) &&
     71        get_option ( 'myoptionalmodules_miniloopstyle' ) &&
     72        get_option ( 'myoptionalmodules_miniloopmeta' )
     73    ) {
    6174        include ( 'function.shortcode.myoptionalmodules-miniloop.php' );
    6275    }
     
    6982include ( 'class.myoptionalmodules-modules.php' );
    7083
     84/**
     85 * Admin functionality
     86 */
    7187if( current_user_can( 'edit_dashboard' ) && is_admin() ) {
    7288    class myoptionalmodules_admin_css {
  • my-optional-modules/trunk/readme.txt

    r1255259 r1260100  
    11=== My Optional Modules ===
    22Contributors: boyevul
    3 Tags: reddit, meta, og, twitter, facebook, google, description, title, 404, comments, version, pingbacks, author, date, archives, disable, horizontal, galleries, font awesome, share, RSS, DNSBL, garbage, removal, trash, footer, lazy load, exclude, remove, hide, front page, search results, authors, categories, tags, single post, miniloop, attachment, media, embedder, oEmbed
     3Tags: reddit, meta, og, twitter, facebook, google, description, title, 404, comments, version, pingbacks, author, date, archives, disable, horizontal, galleries, font awesome, share, RSS, DNSBL, garbage, removal, trash, footer, exclude, remove, hide, front page, search results, authors, categories, tags, single post, miniloop, attachment, media, embedder, oEmbed
    44Requires at least: 4.1
    55Tested up to: 4.3.2
    6 Stable tag: 10.1.9
     6Stable tag: 10.2
    77
    88An assortment of functions to enhance WordPress.
     
    105105
    106106== Changelog ==
     107= 10.2 =
     108*   *Release Date - 5th, October, 2015*
     109*   fixed an error when excluding posts based on user levels
     110
    107111= 10.1.9 =
    108112*   *Release Date - 28th, September, 2015*
Note: See TracChangeset for help on using the changeset viewer.