Plugin Directory

Changeset 194466


Ignore:
Timestamp:
01/16/2010 04:05:51 PM (16 years ago)
Author:
Funnnny
Message:

2.3.8

Location:
hidepost
Files:
13 added
3 edited

Legend:

Unmodified
Added
Removed
  • hidepost/trunk/hidepost.php

    r118934 r194466  
    44Plugin URI: http://nguyenthanhcong.com/hidepost-plugin-for-wordpress/
    55Description: Protect a part of your post by using [hidepost] and [/hidepost]  between the protected content.
    6 Version: 2.3.7
     6Version: 2.3.8
    77Author: Fu4ny
    88Author URI: http://nguyenthanhcong.com
     
    3939}
    4040
     41function hidepost_text_content() {
     42    global $hidepost_content_text, $hidepost_content_text_hide;
     43    if ($hidepost_content_text_hide != 1) return $hidepost_content_text;
     44        else return '';
     45}
     46
     47function hidepost_role_text($hidepost_max_level) {
     48    global $hidepost_role_text, $hidepost_role_text_hide;
     49    switch ($hidepost_max_level):
     50        case 0: $show = 'Subscriber';
     51            break;
     52        case 1: $show = 'Contributor';
     53            break;
     54        case 2: $show = 'Author';
     55            break;
     56        case 3:
     57        case 4:
     58        case 5:
     59        case 6:
     60        case 7: $show = 'Editor';
     61            break;
     62        case 8:
     63        case 9: $show = 'Administrator';
     64            break;
     65    endswitch;
     66    $hidepost_role_text = str_replace('%role%',$show,$hidepost_role_text);
     67    if ($hidepost_role_text_hide != 1) return $hidepost_role_text;
     68    else return '';
     69}
     70
     71if(!function_exists('hidethis')) {
     72
     73function hidethis( $content, $level=0,$display = true  ) {
     74    global $current_user, $user_ID, $user_level;
     75    get_currentuserinfo();
     76    if ($user_ID == '') {//If not logged in
     77        if ( $display ) { echo hidepost_text_content(); }
     78        else return hidepost_text_content();
     79    } else if ($user_level < $level){ //Not meet the require level
     80        if ( $display ) { echo hidepost_role_text($level); }
     81        else return hidepost_role_text($level);
     82    } else {
     83        if ( $display ) { echo $content; }
     84        else return $content;
     85    }
     86}
     87
     88}
     89
    4190function hidepost_replace_hide($content) {
    42     global $current_user, $user_ID, $hidepost_content_text,$user_level, $m_id, $hidepost_role_text, $hidepost_role_text_hide, $hidepost_content_text_hide;
     91    global $current_user, $user_ID,$user_level, $m_id;
    4392    $m_id++;
    4493    preg_match_all('#\[hidepost(.*?)\](.*?)\[/hidepost\]#sie', $content, $matches);//Find the hidepost tag
     
    58107    get_currentuserinfo();
    59108    if ($user_ID == ''){//If not logged in
    60         if ($hidepost_content_text_hide != 1) return $hidepost_content_text;
    61         else return '';
     109        return hidepost_text_content();
    62110    }
    63111    if ($user_level < $hidepost_max_level) {//Not meet the require level
    64         switch ($hidepost_max_level):
    65             case 0: $show = 'Subscriber';
    66                     break;
    67             case 1: $show = 'Contributor';
    68                     break;
    69             case 2: $show = 'Author';
    70                     break;
    71             case 3:
    72             case 4:
    73             case 5:
    74             case 6:
    75             case 7: $show = 'Editor';
    76                     break;
    77             case 8:
    78             case 9: $show = 'Administrator';
    79                     break;
    80         endswitch;
    81         $hidepost_role_text = str_replace('%role%',$show,$hidepost_role_text);
    82         if ($hidepost_role_text_hide != 1) return $hidepost_role_text; else return '';
     112        return hidepost_role_text($hidepost_max_level);
    83113    }
    84114    return $matches[2][$m_id]; //Return the content if user can see
     
    90120    preg_match_all('#\<a(.*?)\>(.*?)\</a\>#sie', $content, $matches);  //Find all the link
    91121    get_currentuserinfo();
     122    if ( strpos($matches[0][$m_id],"class=\"more-link\"") != false ) {//Hacked
     123        return $matches[0][$m_id];
     124    }
    92125    if ($user_ID == ''){//If not logged in
    93126        if ($hidepost_link_text_hide != 1) return $hidepost_link_text; else return '';
     
    110143    return $content;
    111144}
     145
     146
    112147
    113148//Add the Option Page
     
    165200add_action('admin_menu', 'hidepost_options');
    166201add_filter('the_content', 'hidepost_filter_post');
    167 add_filter('the_exceprt', 'hidepost_filter_post');
     202add_filter('the_excerpt', 'hidepost_filter_post');
     203add_filter('the_excerpt_rss', 'hidepost_filter_post');
    168204
    169205//Function: Add Quick Tag For HidePost In TinyMCE >= WordPress 2.5
     
    191227function hidepost_quicktag_footer(){
    192228    echo '<script type="text/javascript">'."\n";
     229    echo "\t".'function insertLevel() {'."\n";
     230    echo "\t".'var hidepost_level = prompt(" Enter the lowest user level that can read the content ( default is 0 )","0");'."\n";
     231    echo "\t".'return hidepost_level;'."\n";
     232    echo "\t".'}'."\n";
    193233    echo "\t".'function insertHidepost_qt( myField ) {'."\n";
    194234    echo "\t\t".'var hidepost_startPos = myField.selectionStart;'."\n";
  • hidepost/trunk/readme.txt

    r167874 r194466  
    11=== HidePost ===
    22Contributors: Funnnny
    3 Tags: protect, hidepost, post, restrict, restriction
     3Tags: protect, hidepost, post
    44Requires at least: 1.5
    5 Tested up to: 2.9
    6 Stable tag: 2.3.7
    7 Donate link: http://nguyenthanhcong.com/donations/
     5Tested up to: 2.8
     6Stable tag: 2.3.8
    87
    98Protect your post or your link by using [hidepost] and [/hidepost] between the protected content.
     
    20192. Activate it
    21203. Go to Option -> Hidepost and check "Enable HidePost"
    22 4. Use [hidepost] tag to protect the content
     214.1 Use [hidepost=level] tag to protect the content
     224.2 Or put the function <?php hidethis($string,$level); ?> in the template
    2323
    2424= Upgrade =
     
    133133
    134134=2.3.6 (11/02/2009)=
     135
    135136Fixed error with exceprt and wrong user level.
     137
    136138Some changes in option page
    137139
    138140=2.3.7 (19/05/2009)=
     141
    139142Add quick button to add Hidepost's tag in TinyMCE editor
     143
     144=2.3.8 (16/01/2010)=
     145
     146Fixed bug with RSS and Readmore link
     147
     148Added a template call
  • hidepost/trunk/tinymce/plugins/hidepost/editor_plugin.js

    r118934 r194466  
    3636}
    3737
    38 function insertLevel() {
    39     var hidepost_level = prompt(" Enter the lowest user level that can read the content ( default is 0 )","0");
    40     return hidepost_level;
    41 }
    42 
    4338//returns the selected text from the editor
    4439function TinyMCE_getSelectedText(){
Note: See TracChangeset for help on using the changeset viewer.