Plugin Directory

Changeset 781826


Ignore:
Timestamp:
10/03/2013 12:36:13 PM (12 years ago)
Author:
tarasm
Message:

Upgrade to 1.5

Location:
dmca-badge/trunk
Files:
310 added
13 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • dmca-badge/trunk/dmca-badge.php

    r463163 r781826  
    11<?php
    22/*
    3 Plugin Name:     DMCA Website Protection
    4 Description:       Protect your content with a DMCA.com Website Protection Badge. Our badges deter content theft, provide tracking of unauthorized usage (with account), and make takedowns easier and more effective. Visit the plugin site to learn more about DMCA Website Protection Badges, or to register.
    5 Version:           1.1
     3Plugin Name: DMCA Website Protection Badge
     4Plugin URI: http://www.google.com/
     5Description: Protect your content with a DMCA.com Website Protection Badge. Our badges deter content theft, provide tracking of unauthorized usage (with account), and make takedowns easier and more effective. Visit the plugin site to learn more about DMCA Website Protection Badges, or to register.
     6Version:           1.5
    67Author:            DMCA.com
    7 Author URI:        http://wordpress.org/extend/plugins/dmca-badge/   
     8Author URI:        http://wordpress.org/plugins/dmca-badge/
    89Plugin URI:        http://dmca.com
    9 */
     10License: GPLv2
     11 */
    1012
    11 DMCA_Badge::init();
     13require( dirname( __FILE__ ) . '/libraries/imperative/imperative.php' );
    1214
    13 /**
    14  * DMCA_Badge
    15  *
    16  * DONE
    17  * =====
    18  * - Enter GUID obtained from DMCA.com
    19  * - Checkbox to disable badge placement at end of every post
    20  * - Checkbox to enable display badge on "Pages" in addition to "Posts".
    21  * - List of Post Types to display badge on.
    22  * - Select from one of several Badges.
    23  *
    24  *
    25  * @since      2011-08-27
    26  */
    27 class DMCA_Badge {
    28     const domain          = 'dmca_badge';
    29     const version         = '0.1';
    30     static $url           = 'https://www.dmca.com/rest';
    31     static $settings_page = null;
     15require_library( 'restian', '0.4.0',  __FILE__, 'libraries/restian/restian.php' );
     16require_library( 'sidecar', '0.5.0', __FILE__, 'libraries/sidecar/sidecar.php' );
     17require_library( 'dmca-api-client', '0.1.0', __FILE__, 'libraries/dmca-api-client/dmca-api-client.php' );
    3218
    33     /**
    34      * Hook into WordPress.
    35      *
    36      * @since      2011-08-27
    37      */
    38     static function init() {
     19register_plugin_loader( __FILE__ );
    3920
    40         /* Admin Hooks. */
    41         add_action( 'plugins_loaded',       array( __CLASS__, 'load_textdomain' ) );
    42         add_action( 'admin_menu',           array( __CLASS__, 'settings_menu' ),    10 );
    43         add_action( 'admin_menu',           array( __CLASS__, 'settings_enqueue' ), 11 );
    44         add_action( 'admin_init',           array( __CLASS__, 'settings_register' ) );
    45         add_filter( 'plugin_action_links',  array( __CLASS__, 'add_settings_link' ), 10, 2 );
    46 
    47         /* Front End Hooks */
    48         add_action( 'widgets_init', array( __CLASS__, 'register_dmca_badge_widget' ) );
    49 
    50         /* Public Hooks. */
    51         add_action( 'template_redirect', array( __CLASS__, 'integrate_singular' ) );
    52         add_action( 'template_redirect', array( __CLASS__, 'integrate_multiple' ) );
    53     }
    54 
    55     /**
    56      * Add settings link to plugin listing on plugins page.
    57      *
    58      * @since      2011-09-19
    59      */
    60     static function add_settings_link( $links, $file ){
    61         if( $file == plugin_basename(__FILE__) ){
    62             $settings_link = '<a href="'.admin_url('options-general.php?page=dmca_badge').'">'.__('Settings', self::domain).'</a>';
    63             array_unshift($links, $settings_link);
    64         }
    65         return $links;
    66     }
    67 
    68     /**
    69      * Load Text Domain.
    70      *
    71      * @since      2011-08-27
    72      */
    73     static function load_textdomain() {
    74         load_plugin_textdomain( self::domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    75     }
    76 
    77     /**
    78      * Dynamic hooks for Settings page.
    79      *
    80      * @since      2011-08-27
    81      */
    82     static function settings_enqueue() {
    83         add_action( 'admin_print_styles-' . self::$settings_page, array( __CLASS__, 'style_settings_page' ) );
    84         add_action( 'admin_print_scripts-' . self::$settings_page, array( __CLASS__, 'script_settings_page' ) );
    85     }
    86 
    87     /**
    88      * Settings Page Styles.
    89      *
    90      * @since      2011-08-27
    91      */
    92     static function style_settings_page() {
    93         wp_enqueue_style(
    94             self::domain . '_settings',
    95             plugin_dir_url( __FILE__ ) . 'style-settings-page.css',
    96             array(),
    97             self::version,
    98             'screen'
    99         );
    100     }
    101 
    102     /**
    103      * Settings Page Scripts.
    104      *
    105      * @since      2011-08-27
    106      */
    107     static function script_settings_page() {
    108         wp_enqueue_script(
    109             self::domain . '_settings',
    110             plugin_dir_url( __FILE__ ) . 'script-settings-page.js',
    111             array('jquery'),
    112             self::version,
    113             false
    114         );
    115     }
    116 
    117     /**
    118      * Integrate into singular templates.
    119      *
    120      * @since      2011-08-27
    121      */
    122     static function integrate_singular() {
    123         $settings = self::get_settings();
    124 
    125         if ( empty( $settings['singular'] ) ) {
    126             return;
    127         }
    128 
    129         if ( empty( $settings['post_types'] ) ) {
    130             return;
    131         }
    132 
    133         if ( ! is_singular( $settings['post_types'] ) ) {
    134             return;
    135         }
    136 
    137         foreach ( $settings['singular'] as $location ) {
    138             switch ( $location ) {
    139                 case 'before_content' :
    140                     add_filter( 'the_content', array( __CLASS__, 'prepend' ) );
    141                     break;
    142                 case 'after_content' :
    143                     add_filter( 'the_content', array( __CLASS__, 'append' ) );
    144                     break;
    145                 default :
    146                     continue;
    147                     break;
    148             }
    149         }
    150     }
    151 
    152     /**
    153      * Integrate into archive templates.
    154      *
    155      * @since      2011-08-27
    156      */
    157     static function integrate_multiple() {
    158         $settings = self::get_settings();
    159 
    160         if ( empty( $settings['multiple'] ) ) {
    161             return;
    162         }
    163 
    164         if ( is_singular() ) {
    165             return;
    166         }
    167 
    168         foreach ( $settings['multiple'] as $location ) {
    169             switch ( $location ) {
    170                 case 'before_content' :
    171                     add_filter( 'the_content', array( __CLASS__, 'prepend_archive' ) );
    172                     break;
    173                 case 'after_content' :
    174                     add_filter( 'the_content', array( __CLASS__, 'append_archive' ) );
    175                     break;
    176                 case 'before_excerpt' :
    177                     add_filter( 'the_excerpt', array( __CLASS__, 'prepend_archive' ) );
    178                     break;
    179                 case 'after_excerpt' :
    180                     add_filter( 'the_excerpt', array( __CLASS__, 'append_archive' ) );
    181                     break;
    182                 default :
    183                     continue;
    184                     break;
    185             }
    186         }
    187     }
    188 
    189     /**
    190      * Generate a button.
    191      *
    192      * Recognized Arguments
    193      *
    194      * count (string) - Either "true" or "false".
    195      * markup (string) - Either "html" or "xhtml".
    196      * size (string) - Either "small", "medium", "standard" or "tall".
    197      * url (string) - The url to send to Google.
    198      *
    199      * @param      array        Arguments to customize the button.
    200      *
    201      * @since      2011-08-27
    202      */
    203     static function button( $args = array() ) {
    204         $alignment = esc_attr( self::get_setting( 'alignment' ) );
    205         $class = ( empty($alignment) ) ? 'dmca_badge' : 'dmca_badge ' . $alignment;
    206         return '<div class="' . $class . '">' . self::link() . '</div>';
    207     }
    208 
    209     /**
    210      * Get badge HTML
    211      *
    212      * @since       2011-09-14
    213      */
    214     static function link(){
    215         return html_entity_decode( esc_html( self::get_setting( 'badge' ) ) );
    216     }
    217 
    218     /**
    219      * Print a button.
    220      *
    221      * @since      2011-08-27
    222      */
    223     static function button_print( $args = array() ) {
    224         print "\n" . self::button( $args );
    225     }
    226 
    227     /**
    228      * Prepend button to element in the loop.
    229      *
    230      * @since      2011-08-27
    231      */
    232     static function prepend( $content ) {
    233         if ( ! in_the_loop() ) {
    234             return $content;
    235         }
    236         return self::button() . $content;
    237     }
    238 
    239     /**
    240      * Prepend button to element in archive view.
    241      *
    242      * @since      2011-08-27
    243      */
    244     static function prepend_archive( $content ) {
    245         $settings = self::get_settings();
    246         if ( empty( $settings['post_types'] ) ) {
    247             return $content;
    248         }
    249         if ( ! in_array( get_post_type(), $settings['post_types'] ) ) {
    250             return $content;
    251         }
    252         return self::prepend( $content );
    253     }
    254 
    255     /**
    256      * Append button to element in the loop.
    257      *
    258      * @since      2011-08-27
    259      */
    260     static function append( $content ) {
    261         if ( ! in_the_loop() ) {
    262             return $content;
    263         }
    264         return $content . self::button();
    265     }
    266 
    267     /**
    268      * Append button to element in archive view.
    269      *
    270      * @since      2011-08-27
    271      */
    272     static function append_archive( $content ) {
    273         $settings = self::get_settings();
    274         if ( empty( $settings['post_types'] ) ) {
    275             return $content;
    276         }
    277         if ( ! in_array( get_post_type(), $settings['post_types'] ) ) {
    278             return $content;
    279         }
    280         return self::append( $content );
    281     }
    282 
    283     /**
    284      * Add Link to Admin Menu.
    285      *
    286      * @since      2011-08-27
    287      */
    288     static function settings_menu() {
    289         self::$settings_page = add_options_page(
    290             __( 'DMCA Website Protection', self::domain ),
    291             __( 'DMCA Website Protection', self::domain ),
    292             'manage_options',
    293             self::domain,
    294             array( __CLASS__, 'settings_page' )
    295             );
    296     }
    297 
    298     /**
    299      * Register Setting + Admin Panel.
    300      *
    301      * @since      2011-08-27
    302      */
    303     static function settings_register() {
    304         register_setting(
    305             self::domain,
    306             self::domain,
    307             array( __CLASS__, 'settings_sanitize' )
    308             );
    309         add_settings_section(
    310             self::domain . '_readme',
    311             __( 'Learn More About This Plugin', self::domain ),
    312             array( __CLASS__, 'message_readme' ),
    313             self::domain
    314             );
    315         add_settings_section(
    316             self::domain . '_free_account',
    317             __( 'Create A New FREE Account', self::domain ),
    318             array( __CLASS__, 'message_free_account' ),
    319             self::domain
    320             );
    321         add_settings_field(
    322             self::domain . '_free_first_name',
    323             __( 'First Name: *', self::domain ),
    324             array( __CLASS__, 'control_free_first_name' ),
    325             self::domain,
    326             self::domain . '_free_account'
    327             );
    328         add_settings_field(
    329             self::domain . '_free_last_name',
    330             __( 'Last Name: *', self::domain ),
    331             array( __CLASS__, 'control_free_last_name' ),
    332             self::domain,
    333             self::domain . '_free_account'
    334             );
    335         add_settings_field(
    336             self::domain . '_free_email',
    337             __( 'Email Address: *', self::domain ),
    338             array( __CLASS__, 'control_free_email' ),
    339             self::domain,
    340             self::domain . '_free_account'
    341             );
    342         add_settings_field(
    343             self::domain . '_free_company_name',
    344             __( 'Company Name:', self::domain ),
    345             array( __CLASS__, 'control_free_company_name' ),
    346             self::domain,
    347             self::domain . '_free_account'
    348             );
    349         add_settings_field(
    350             self::domain . '_create_account',
    351             __( '', self::domain ),
    352             array( __CLASS__, 'control_create_account' ),
    353             self::domain,
    354             self::domain . '_free_account'
    355             );
    356         add_settings_field(
    357             self::domain . '_fetch_pro',
    358             false,
    359             array( __CLASS__, 'control_fetch_pro' ),
    360             self::domain,
    361             self::domain . '_free_account'
    362         );
    363 
    364 
    365         add_settings_section(
    366             self::domain . '_pro_account',
    367             __( 'Already have an account?', self::domain ),
    368             array( __CLASS__, 'message_pro_account' ),
    369             self::domain
    370             );
    371         add_settings_field(
    372             self::domain . '_pro_username',
    373             __( 'Username/Email:', self::domain ),
    374             array( __CLASS__, 'control_pro_username' ),
    375             self::domain,
    376             self::domain . '_pro_account'
    377             );
    378         add_settings_field(
    379             self::domain . '_pro_password',
    380             __( 'Password:', self::domain ),
    381             array( __CLASS__, 'control_pro_password' ),
    382             self::domain,
    383             self::domain . '_pro_account'
    384             );
    385         add_settings_field(
    386             self::domain . '_fetch_pro',
    387             false,
    388             array( __CLASS__, 'control_fetch_pro' ),
    389             self::domain,
    390             self::domain . '_pro_account'
    391         );
    392 /*
    393 * Badge Selection
    394 */
    395         add_settings_section(
    396             self::domain . '_configuration',
    397             __( 'Select a Badge', self::domain ),
    398             array( __CLASS__, 'message_configuration' ),
    399             self::domain
    400             );
    401         add_settings_field(
    402             self::domain . '_badge',
    403             __( 'Currently Selected Badge', self::domain ),
    404             array( __CLASS__, 'control_badge' ),
    405             self::domain,
    406             self::domain . '_configuration'
    407             );
    408         add_settings_field(
    409             self::domain . '_badge_select',
    410             __( 'Choose your badge', self::domain ),
    411             array( __CLASS__, 'control_badge_select' ),
    412             self::domain,
    413             self::domain . '_configuration'
    414             );
    415           add_settings_field(
    416             self::domain . '_fetch_pro',
    417             false,
    418             array( __CLASS__, 'control_fetch_pro' ),
    419             self::domain,
    420             self::domain . '_configuration'
    421         );
    422 
    423 
    424 /*
    425 Theme Integration Settings
    426 */
    427  
    428         add_settings_section(
    429             self::domain . '_theme_integration',
    430             __( 'Theme Integration', self::domain ),
    431             array( __CLASS__, 'message_theme_integration' ),
    432             self::domain
    433             );
    434         add_settings_field(
    435             self::domain . '_singular',
    436             __( 'Singular Templates', self::domain ),
    437             array( __CLASS__, 'control_singular' ),
    438             self::domain,
    439             self::domain . '_theme_integration'
    440             );
    441         add_settings_field(
    442             self::domain . '_multiple',
    443             __( 'Archive Templates', self::domain ),
    444             array( __CLASS__, 'control_multiple' ),
    445             self::domain,
    446             self::domain . '_theme_integration'
    447             );
    448         add_settings_field(
    449             self::domain . '_post_types',
    450             __( 'Post Types', self::domain ),
    451             array( __CLASS__, 'control_post_types' ),
    452             self::domain,
    453             self::domain . '_theme_integration'
    454             );
    455         add_settings_field(
    456             self::domain . '_alignment',
    457             __( 'Alignment', self::domain ),
    458             array( __CLASS__, 'control_alignment' ),
    459             self::domain,
    460             self::domain . '_theme_integration'
    461             );
    462                add_settings_field(
    463             self::domain . '_fetch_pro',
    464             false,
    465             array( __CLASS__, 'control_fetch_pro' ),
    466             self::domain,
    467             self::domain . '_theme_integration'
    468         );
    469 
    470         add_settings_section(
    471             self::domain . '_widget',
    472             __( 'Use the Widget to place a DMCA Website Protection Badge in your sidebar or footer.', self::domain ),
    473             array( __CLASS__, 'message_widget' ),
    474             self::domain
    475             );
    476     }
    477 
    478     /**
    479      * Message for Widget section of settings page.
    480      *
    481      * @since      2011-09-13
    482      */
    483     static function message_widget() {
    484         echo '<p>';
    485         esc_html_e( 'You can place a DMCA Website Protection Badge in your sidebar or footer by using the Widget. ', self::domain );
    486         echo sprintf( '<a href="%s">%s</a>', admin_url('widgets.php'), __('Go to the Widgets page now!', self::domain) );
    487         echo '</p>';
    488     }
    489 
    490     /**
    491      * Message for Pro Account section of settings page.
    492      *
    493      * @since      2011-09-13
    494      */
    495     static function message_readme() {
    496         echo sprintf( '<div style="float:right; text-align:center;">example certificate</br> <img  src="%s" >%s</img></div>', plugins_url( 'images/certificate.png', __FILE__) , __(' ', self::domain) );
    497         echo '<p>';
    498         echo 'DMCA.com offers FREE services to protect your site from content theft. <br> To learn more about the DMCA.com Website Protection Program visit: ';
    499         echo sprintf( '<a href="%s" target="_blank">%s</a>', "http://www.dmca.com/Protection.aspx", __('www.dmca.com', self::domain) );
    500         echo '</p>';
    501         echo '<p>';
    502         esc_html_e( 'Each page you have a DMCA Badge on is tracked by DMCA.com and issued a certificate. If someone steals your content while it is under DMCA.com protection DMCA.com will perform a Free DMCA Takedown on your behalf.', self::domain );
    503         echo '</p>';
    504        
    505        
    506         echo '<p>';
    507         esc_html_e( 'View the readme for the DMCA Website Protection Badge Plugin: ', self::domain );
    508         echo sprintf( '<a href="%s">%s</a>', plugins_url( 'readme.html', __FILE__ ), __('ReadMe.html', self::domain) );
    509         echo '</p>';
    510        
    511 
    512     }
    513    
    514    
    515     /**
    516      * Message forFree Account section of settings page.
    517      *
    518      * @since      2011-10-09
    519      */
    520     static function message_free_account() {
    521         echo '<p>';
    522           esc_html_e( 'To create your new free account fill in the fields. Once you click Save Settings, check your email for a confirmation message.', self::domain );
    523         echo '</p>';
    524         echo '<p>';
    525           esc_html_e( 'Fields marked * are required.', self::domain );
    526         echo '<br>';
    527         echo '</p>';
    528 
    529     }
    530 
    531     /**
    532      * Message for Pro Account section of settings page.
    533      *
    534      * @since      2011-09-13
    535      */
    536     static function message_pro_account() {
    537         echo '<p>';
    538           esc_html_e( 'If you already have a DMCA Website Protection account, enter your account information so you can use our authenticated badges. To enable the appropriate selection of badges for your website, be sure to Save Changes before selecting a badge.', self::domain );
    539         echo '<br>';
    540         echo '<strong>';
    541         esc_html_e( 'To register your FREE account, and to learn more about DMCA Website Protection visit: ', self::domain );
    542         echo '</strong>';
    543         echo sprintf( '<a href="%s" target="_blank" >%s</a>', "http://www.dmca.com/Badges.aspx", __('www.dmca.com', self::domain) );
    544         echo '</p>';
    545 
    546     }
    547 
    548 
    549     /**
    550      * Message for Configuration section of settings page.
    551      *
    552      * @since      2011-08-27
    553      */
    554     static function message_configuration() {
    555         esc_html_e( 'Select a DMCA Website Protection Badge by clicking on it.', self::domain );
    556     }
    557 
    558     /**
    559      * Message for Theme Integration section of settings page.
    560      *
    561      * @since      2011-08-27
    562      */
    563     static function message_theme_integration() {
    564         print sprintf( esc_html__( 'The following settings enable you to automatically add DMCA Website Protection Badges at different places in your theme. You can control whether the badge appears on a single post/page, on your front page, or an archive page. Optionally, use the widget (see below) to place your Badge into a sidebar or footer area of your site. You must adjust these settings so that your badges will appear.', self::domain ));
    565     }
    566 
    567     /**
    568      * Settings Page Template.
    569      *
    570      * @since      2011-08-27
    571      */
    572     static function settings_page() {
    573         print "\n" . '<div class="wrap" id="' . esc_attr( self::$settings_page ) . '">';
    574         screen_icon();
    575         print "\n" . '<h2>' . esc_html__( 'DMCA Website Protection Settings', self::domain ) . '</h2>';
    576         print "\n" . '<form action="options.php" method="post">';
    577 
    578         settings_fields( self::domain );
    579         do_settings_sections( self::domain );
    580 
    581 //      print "\n" . '<div class="button-holder"><input name="submit" type="submit" value="' . esc_attr__( 'Save Changes', self::domain ) . '" /></div>';
    582         print "\n" . '</div></form>';
    583     }
    584 
    585     /**
    586      * Free First Name UI
    587      *
    588      * @since      2011-10-09
    589      */
    590     static function control_free_first_name(){
    591         $key = 'free_first_name';
    592         $id = self::domain . '_' . $key;
    593         $saved = self::get_setting( $key );
    594         echo '<div id="' . $id . '_wrap">';
    595         echo '<input type="text" id="' . $id . '" class="' . $id . '" name="' . self::domain . '[' . $key . ']' . '" value="' . esc_attr('') . '" />';
    596         echo '</div>';
    597     }
    598 
    599     /**
    600      * Free Last Name UI
    601      *
    602      * @since      2011-10-09
    603      */
    604     static function control_free_last_name(){
    605         $key = 'free_last_name';
    606         $id = self::domain . '_' . $key;
    607         $saved = self::get_setting( $key );
    608         echo '<div id="' . $id . '_wrap">';
    609         echo '<input type="text" id="' . $id . '" class="' . $id . '" name="' . self::domain . '[' . $key . ']' . '" value="' . esc_attr('') . '" />';
    610         echo '</div>';
    611     }
    612 
    613     /**
    614      * Free Company Name UI
    615      *
    616      * @since      2011-09-13
    617      */
    618     static function control_free_company_name(){
    619         $key = 'free_company_name';
    620         $id = self::domain . '_' . $key;
    621         $saved = self::get_setting( $key );
    622         echo '<div id="' . $id . '_wrap">';
    623         echo '<input type="text" id="' . $id . '" class="' . $id . '" name="' . self::domain . '[' . $key . ']' . '" value="' . esc_attr('') . '" />';
    624         echo '</div>';
    625 //        echo '<br>' ;
    626     }
    627 
    628 
    629     /**
    630      * Free Email UI
    631      *
    632      * @since      2011-09-13
    633      */
    634     static function control_free_email(){
    635         $key = 'free_email';
    636         $id = self::domain . '_' . $key;
    637         $saved = self::get_setting( $key );
    638         echo '<div id="' . $id . '_wrap">';
    639         echo '<input type="text" id="' . $id . '" class="' . $id . '" name="' . self::domain . '[' . $key . ']' . '" value="' . esc_attr('') . '" />';
    640         echo '</div>';
    641     }
    642 
    643 
    644     /**
    645      * Free Account UI
    646      *
    647      * @since      2011-09-13
    648      */
    649     static function control_create_account(){
    650         $key = 'create_account';
    651         $id = self::domain . '_' . $key;
    652         echo '<div id="' . $id . '_wrap">';
    653             if( self::get_setting('free_first_name') && self::get_setting('free_last_name') && self::get_setting('free_email')   ){
    654            $url = self::$url . '/RegisterNewAccount';
    655            $response = wp_remote_request( $url, array(
    656                 'method' => 'POST',
    657                 'headers' => array(
    658                'content-type' => 'application/json; charset=utf-8',
    659             ),
    660              'body' =>  '{"FirstName":"'.self::get_setting('free_first_name').'","LastName":"'.self::get_setting('free_last_name').'",
    661                     "CompanyName":"'.self::get_setting('free_company_name').'","Email":"'.self::get_setting('free_email').'"}',
    662               'sslverify' => false,
    663               ) );
    664              
    665             if( wp_remote_retrieve_response_code( $response ) == 200 ){
    666                 echo '<p style="color:red;">' . __('New Account Created. Check Your Email For Confirmation.', self::domain ) . '</p>';
    667           } else{
    668                 echo '<p style="color:red;">' . __('There was a problem creating your account. Please try again.', self::domain ) . '</p>';
    669                echo wp_remote_retrieve_response_code( $response ) . '<br>';
    670                echo $response . '<br>';
    671            }
    672 
    673         }
    674         echo '</div>';
    675      }
    676 
    677 
    678 
    679     /**
    680      * Pro Username UI
    681      *
    682      * @since      2011-09-13
    683      */
    684     static function control_fetch_pro(){
    685         echo '<input type="submit" class="button-primary" name="submit" value="' . __( 'Save Settings', self::domain ) . '" />';
    686     }
    687 
    688     /**
    689      * Pro Username UI
    690      *
    691      * @since      2011-09-13
    692      */
    693     static function control_pro_username(){
    694         $key = 'pro_username';
    695         $id = self::domain . '_' . $key;
    696         $saved = self::get_setting( $key );
    697         echo '<div id="' . $id . '_wrap">';
    698         echo '<input type="text" id="' . $id . '" class="' . $id . '" name="' . self::domain . '[' . $key . ']' . '" value="' . esc_attr($saved) . '" />';
    699         echo '</div>';
    700     }
    701 
    702     /**
    703      * Pro Password UI
    704      *
    705      * @since      2011-09-13
    706      */
    707     static function control_pro_password(){
    708         $key = 'pro_password';
    709         $id = self::domain . '_' . $key;
    710         $saved = self::get_setting( $key );
    711         echo '<div id="' . $id . '_wrap">';
    712         echo '<input type="password" id="' . $id . '" class="' . $id . '" name="' . self::domain . '[' . $key . ']' . '" value="' . esc_attr($saved) . '" />';
    713         echo '</div>';
    714     }
    715 
    716     /**
    717      * Current Badge UI
    718      *
    719      * @since     2011-09-13
    720      */
    721     static function control_badge(){
    722         $key = 'badge';
    723         $id = self::domain . '_' . $key;
    724         $saved = self::get_setting( $key );
    725         echo '<div id="' . $id . '_wrap">';
    726         echo '<div id="current-' . $key . '">' . html_entity_decode( esc_html( $saved ) ) . '</div>';
    727         echo '<textarea id="' . $id . '" class="' . $id . '" name="'. self::domain . '[' . $key . ']' .'" rows="3" cols="40">' . esc_attr( $saved ) . '</textarea>';
    728         echo '</div>';
    729     }
    730 
    731     /**
    732      * Badge Selection UI
    733      *
    734      * @since     2011-09-13
    735      */
    736     static function control_badge_select(){
    737         if( self::get_setting('pro_username') && self::get_setting('pro_password') ){
    738             self::display_pro_badges( self::get_setting('pro_username'), self::get_setting('pro_password') );
    739         } else {
    740             self::display_badges();
    741         }
    742     }
    743 
    744      
    745 
    746     /**
    747      * Display Anonymous Badges
    748      *
    749      * @since     2011-09-13
    750      */
    751     static function display_badges(){
    752         $url = self::$url . '/GetAnonymousBadges';
    753         $response = wp_remote_request( $url, array( 'sslverify' => false ) );
    754         if( wp_remote_retrieve_response_code( $response ) == 200 ){
    755             $html = new SimpleXMLElement( html_entity_decode( wp_remote_retrieve_body( $response ) ) );
    756             echo '<div id="badge_selector_wrapper">';
    757             echo '<div id="badge_selector">';
    758             foreach( $html->a as $badge ){
    759                 echo '<div class="badge">'.$badge->asXML() . '</div>';
    760             }
    761             echo '</div>';
    762             echo '</div>';
    763             return;
    764         } else {
    765             _e('<p>Sorry, we were unable to retrieve available badges.</p>', self::domain);
    766         }
    767     }
    768 
    769     /**
    770      * Display Authenticated Badges
    771      *
    772      * @since     2011-09-13
    773      */
    774     static function display_pro_badges( $email, $password ){
    775         $url = self::$url . '/GetAuthenticatedBadges';
    776         $failure = __( 'Sorry, we were unable to load your authenticated badges.  Please check your account information and try again.', self::domain );
    777         $response = wp_remote_request( $url, array(
    778             'method' => 'POST',
    779             'headers' => array(
    780                 'content-type' => 'application/json; charset=utf-8',
    781             ),
    782             'body' => '{"Email":"'.$email.'","Password":"'.$password.'"}',
    783             'sslverify' => false,
    784         ) );
    785         if( wp_remote_retrieve_response_code( $response ) == 200 ){
    786             $body = wp_remote_retrieve_body( $response );
    787             if( $body == '<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Login failed</string>' ){
    788                 echo '<p style="color:red;">' . $failure . '</p>';
    789                 self::display_badges();
    790                 return;
    791             }
    792             $html = new SimpleXMLElement( html_entity_decode( $body ) );
    793             echo '<div id="badge_selector_wrapper">';
    794             echo '<div id="badge_selector">';
    795             foreach( $html->a as $badge ){
    796                 echo '<div class="badge">'.$badge->asXML() . '</div>';
    797             }
    798             echo '</div>';
    799             echo '</div>';
    800             return;
    801         } else{
    802             echo '<p style="color:red;">' . $failure . '</p>';
    803             self::display_badges();
    804             return;
    805         }
    806     }
    807 
    808     /**
    809      * Button Alignment UI.
    810      *
    811      * @since      2011-08-27
    812      */
    813     static function control_alignment() {
    814         $key = 'alignment';
    815         $saved = self::get_setting( $key );
    816         print '<div id="' . self::domain . '_' . $key . '_wrap" class="' . esc_attr( self::domain . '_multiple_values' ) . '">';
    817         foreach ( self::get_alignments() as $alignment => $label ) {
    818             $id = self::domain . '_' . $key . '_' . $alignment;
    819             print "\n" . '<label for="' . esc_attr( $id ) . '"><input' . checked( $alignment, $saved, false ) . ' id="' . esc_attr( $id ) . '" type="radio" class="' . self::domain . '_' . $key . '" name="' . self::domain . '[' . $key . ']" value="' . esc_attr( $alignment ) . '" /> ' . esc_html( $label ) . '</label>';
    820         }
    821         print '</div>';
    822     }
    823 
    824     /**
    825      * Singular Template UI.
    826      *
    827      * @since      2011-08-27
    828      */
    829     static function control_singular() {
    830         $key = 'singular';
    831         $saved = self::get_setting( $key );
    832         print '<div id="' . self::domain . '_' . $key . '_wrap" class="' . esc_attr( self::domain . '_multiple_values' ) . '">';
    833         foreach ( self::get_locations_singular() as $location => $label ) {
    834             $id = self::domain . '_' . $key . '_' . $location;
    835             $checked = ( in_array( $location, $saved ) ) ? ' checked="checked"' : '';
    836             print "\n" . '<label for="' . esc_attr( $id ) . '"><input' . $checked . ' id="' . esc_attr( $id ) . '" type="checkbox" name="' . self::domain . '[' . $key . '][]" value="' . esc_attr( $location ) . '" /> ' . esc_html( $label ) . '</label>';
    837         }
    838         print '</div>';
    839     }
    840 
    841     /**
    842      * Multiple Template UI.
    843      *
    844      * @since      2011-08-27
    845      */
    846     static function control_multiple() {
    847         $key = 'multiple';
    848         $saved = self::get_setting( $key );
    849         print '<div id="' . self::domain . '_' . $key . '_wrap" class="' . esc_attr( self::domain . '_multiple_values' ) . '">';
    850         foreach ( self::get_locations_multiple() as $location => $label ) {
    851             $id = self::domain . '_' . $key . '_' . $location;
    852             $checked = ( in_array( $location, $saved ) ) ? ' checked="checked"' : '';
    853             print "\n" . '<label for="' . esc_attr( $id ) . '"><input' . $checked . ' id="' . esc_attr( $id ) . '" type="checkbox" name="' . self::domain . '[' . $key . '][]" value="' . esc_attr( $location ) . '" /> ' . esc_html( $label ) . '</label>';
    854         }
    855         print '</div>';
    856     }
    857 
    858     /**
    859      * Post Type UI.
    860      *
    861      * @since      2011-08-27
    862      */
    863     static function control_post_types() {
    864         $key = 'post_types';
    865         $saved = self::get_setting( $key );
    866         print '<div id="' . self::domain . '_' . $key . '_wrap" class="' . esc_attr( self::domain . '_multiple_values' ) . '">';
    867         foreach ( self::get_post_types() as $post_type => $label ) {
    868             $id = self::domain . '_' . $key . '_' . $post_type;
    869             $checked = ( in_array( $post_type, $saved ) ) ? ' checked="checked"' : '';
    870             print "\n" . '<label for="' . esc_attr( $id ) . '"><input' . $checked . ' id="' . esc_attr( $id ) . '" type="checkbox" name="' . self::domain . '[' . $key .'][]" value="' . esc_attr( $post_type ) . '" /> ' . esc_html( $label ) . '</label>';
    871         }
    872         print '</div>';
    873     }
    874 
    875     /**
    876      * Get Settings.
    877      *
    878      * @since      2011-08-27
    879      */
    880     static function get_settings() {
    881         return wp_parse_args( (array) get_option( self::domain ), self::get_defaults() );
    882     }
    883 
    884     /**
    885      * Get Setting.
    886      *
    887      * Gets an individual key stored in the custom settings array.
    888      * In the event that an unrecognized key is asked for, boolean
    889      * false will be returned.
    890      *
    891      * @param      string       $key Get a single unsanitized setting.
    892      * @return     mixed
    893      *
    894      * @since      2011-08-27
    895      */
    896     static function get_setting( $key ) {
    897         $settings = self::get_settings();
    898         if ( isset( $settings[$key] ) ) {
    899             return $settings[$key];
    900         }
    901         return false;
    902     }
    903 
    904     /**
    905      * Sanitize Settings.
    906      *
    907      * @param      array     $dirty List of values that may be settings.
    908      * @return     array     Sanitized array of all recognized settings.
    909      *
    910      * @since      2011-08-27
    911      */
    912     static function settings_sanitize( $dirty) {
    913         $clean = array(
    914             'alignment'         => 'none',
    915             'badge'             => '',
    916             'language'          => '',
    917             'show_count'        => 'true',
    918             'size'              => '',
    919             'singular'          => array(),
    920             'markup'            => 'html',
    921             'multiple'          => array(),
    922             'post_types'        => array(),
    923             'free_first_name' => '',
    924             'free_last_name' => '',
    925             'free_email' => '',
    926             'free_company_name' => '',
    927          'pro_username'      => '',
    928          'pro_password'      => ''
    929             );
    930 
    931         if ( isset( $dirty['alignment'] ) && array_key_exists( $dirty['alignment'], self::get_alignments() ) ) {
    932             $clean['alignment'] = $dirty['alignment'];
    933         }
    934 
    935         if ( isset( $dirty['badge'] ) ) {
    936             $clean['badge'] = esc_html( $dirty['badge'] );
    937         }
    938 
    939         if ( isset( $dirty['singular'] ) ) {
    940             $locations = self::get_locations_singular();
    941             foreach ( (array) $dirty['singular'] as $location ) {
    942                 if ( array_key_exists( $location, $locations ) ) {
    943                     $clean['singular'][] = $location;
    944                 }
    945             }
    946         }
    947 
    948         if ( isset( $dirty['multiple'] ) ) {
    949             $locations = self::get_locations_multiple();
    950             foreach ( (array) $dirty['multiple'] as $location ) {
    951                 if ( array_key_exists( $location, $locations ) ) {
    952                     $clean['multiple'][] = $location;
    953                 }
    954             }
    955         }
    956 
    957         if ( isset( $dirty['post_types'] ) ) {
    958             $post_types = self::get_post_types();
    959             foreach ( (array) $dirty['post_types'] as $post_type ) {
    960                 if ( array_key_exists( $post_type, $post_types ) ) {
    961                     $clean['post_types'][] = $post_type;
    962                 }
    963             }
    964         }
    965 
    966         if( isset( $dirty['free_first_name'] ) ){
    967             $clean['free_first_name'] = esc_attr( $dirty['free_first_name'] );
    968         }
    969 
    970         if( isset( $dirty['free_last_name'] ) ){
    971             $clean['free_last_name'] = esc_attr( $dirty['free_last_name'] );
    972         }
    973 
    974        if( isset( $dirty['free_email'] ) ){
    975             $clean['free_email'] = esc_attr( $dirty['free_email'] );
    976         }
    977 
    978         if( isset( $dirty['free_company_name'] ) ){
    979             $clean['free_company_name'] = esc_attr( $dirty['free_company_name'] );
    980         }
    981 
    982          if( isset( $dirty['pro_username'] ) ){
    983             $clean['pro_username'] = esc_attr( $dirty['pro_username'] );
    984         }
    985 
    986         if( isset( $dirty['pro_password'] ) ){
    987             $clean['pro_password'] = esc_attr( $dirty['pro_password'] );
    988         }
    989 
    990         if( isset( $dirty['free_email'] ) ){
    991             $clean['free_email'] = esc_attr( $dirty['free_email'] );
    992         }
    993 
    994         if( isset( $dirty['free_company_name'] ) ){
    995             $clean['free_company_name'] = esc_attr( $dirty['free_company_name'] );
    996         }
    997 
    998         return $clean;
    999     }
    1000 
    1001     /**
    1002      * Default Values.
    1003      *
    1004      * @return     array     Default settings.
    1005      *
    1006      * @since      2011-08-27
    1007      */
    1008     static function get_defaults() {
    1009         return array(
    1010             'alignment'  => 'none',
    1011             'language'   => 'en-US',
    1012             'markup'     => 'html',
    1013             'multiple'   => array(),
    1014             'post_types' => array( 'post', 'page' ),
    1015             'show_count' => 'true',
    1016             'singular'   => array(),
    1017             'size'       => 'standard',
    1018             );
    1019     }
    1020 
    1021     /**
    1022      * Get Public Post Types.
    1023      *
    1024      * @return     array     List of public post_type names.
    1025      *
    1026      * @since      2011-08-27
    1027      */
    1028     static function get_post_types() {
    1029         $public = array();
    1030         $post_types = get_post_types();
    1031         foreach ( (array) $post_types as $post_type ) {
    1032             $obj = get_post_type_object( $post_type );
    1033             if ( ! isset( $obj->public ) ) {
    1034                 continue;
    1035             }
    1036             if ( empty( $obj->public ) ) {
    1037                 continue;
    1038             }
    1039             if ( empty( $obj->labels->singular_name ) ) {
    1040                 continue;
    1041             }
    1042             $public[$post_type] = $obj->labels->singular_name;
    1043         }
    1044         return $public;
    1045     }
    1046 
    1047     /**
    1048      * Get Alignments.
    1049      *
    1050      * @return     array     List of supported theme alignments.
    1051      *
    1052      * @since      2011-08-27
    1053      */
    1054     static function get_alignments() {
    1055         return array(
    1056             'none'        => __( 'None',   self::domain ),
    1057             'alignleft'   => __( 'Left',   self::domain ),
    1058             'aligncenter' => __( 'Center', self::domain ),
    1059             'alignright'  => __( 'Right',  self::domain ),
    1060             );
    1061     }
    1062 
    1063     /**
    1064      * Singular Locations.
    1065      *
    1066      * @return     array     List of supported theme locations.
    1067      *
    1068      * @since      2011-08-27
    1069      */
    1070     static function get_locations_singular() {
    1071         return array(
    1072             'before_content' => __( 'Before the Content', self::domain ),
    1073             'after_content'  => __( 'After the Content',  self::domain ),
    1074             );
    1075     }
    1076 
    1077     /**
    1078      * Multiple Locations.
    1079      *
    1080      * @return     array     List of supported theme locations.
    1081      *
    1082      * @since      2011-08-27
    1083      */
    1084     static function get_locations_multiple() {
    1085         return array(
    1086             'before_content' => __( 'Before the Content', self::domain ),
    1087             'after_content'  => __( 'After the Content',  self::domain ),
    1088             'before_excerpt' => __( 'Before the Excerpt', self::domain ),
    1089             'after_excerpt'  => __( 'After the Excerpt',  self::domain ),
    1090             );
    1091     }
    1092 
    1093     /**
    1094      * Register our widget by passing the class name to WordPress
    1095      *
    1096      * @since       2011-09-14
    1097      */
    1098     static function register_dmca_badge_widget(){
    1099         register_widget('DMCA_Widget');
    1100     }
    1101 
    1102 }
    1103 
    1104 class DMCA_Widget extends WP_Widget {
    1105 
    1106     function DMCA_Widget(){
    1107         $this->WP_Widget(
    1108             false,
    1109             __('DMCA Website Protection Badge'),
    1110             array(
    1111                 'classname' => 'dmca_widget_badge',
    1112                 'description' => 'Display your chosen DMCA Website Protection Badge in any widget area of your site.'
    1113             )
    1114         );
    1115     }
    1116 
    1117     function widget( $args, $instance ){
    1118         extract( $args );
    1119         // Begin widget wrapper
    1120         echo $before_widget;
    1121         // Display widget content to user
    1122         echo DMCA_Badge::link();
    1123         // End widget wrapper
    1124         echo $after_widget;
    1125     }
    1126 
    1127 }
  • dmca-badge/trunk/readme.txt

    r453175 r781826  
    55Tested up to: 3.2
    66Plugin URI: http://www.dmca.com/WordPress
    7 Stable tag: 1.1
    8 
     7Stable tag: 1.5
    98
    109The DMCA Protection plugin for WordPress lets you install protection badges on your site in order to deter content thieves and protect your content
    11 
    1210
    1311== Description ==
     
    2018Once installed and activated, you can use the DMCA Protection Badge page in your Dashboard's Settings Menu to specify how your choice of badge should be displayed in posts and pages. You can also choose to display your badge site-wide using the DMCA Badge Widget. You can use the badges for free but we suggest that you sign up for an account at dmca.com in order to receive the full benefit of the certified badges.
    2119
    22 
    2320== Installation ==
    2421
     
    29263. Choose a free badge or provide your DMCA credentials in order to add a badge that is tracked from your DMCA Protection Portal.
    30274. Customize the badge placement in the Theme Options section or add the DMCA Badge widget to your sidebar or footer.
     28
    3129== Frequently Asked Questions ==
    3230
     
    4947Email [email protected] with your case number and request your free takedown.
    5048
    51 
    52 
    5349== Screenshots ==
    5450
    55511. About this plugin.
    56 2. Enter your account if you want badges that are tied to your DMCA Protection Portal. You can skip this step if you want to use the free badge .
    57 3. Current badge.
    58 4. Choose your badge.
    59 5. Choose where you'd like to display your badge on your site. If none are the options are chosen then your badge will not appear within the content.
    60 
    61 
     522. Enter your account if you want badges that are tied to your DMCA Protection Portal.
     533. Choose your badge.
     544. Choose where you'd like to display your badge on your site. If none of the options are chosen then your badge will not appear within the content.
    6255
    6356== Upgrade Notice ==
     57
     58= 1.5 =
     59Admin and code cleanup, no feature changes.
     60
     61== Changelog ==
     62
    6463= 1.1 =
    6564Updated FAQ, no feature changes.
    66 
    67 
    68 == Changelog ==
    6965
    7066= 1.0 =
     
    7369= 1.1 =
    7470Updated FAQ.
    75 
    76 
    77 
Note: See TracChangeset for help on using the changeset viewer.