Plugin Directory

Changeset 734295


Ignore:
Timestamp:
06/30/2013 12:19:42 PM (13 years ago)
Author:
smoo1337
Message:

Version 2.0.2
Bugfix
better Codestyle
Multi Language

Location:
wp-vgwort/trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • wp-vgwort/trunk/class-wp-vgwort.php

    r733723 r734295  
    2424     * @var     string
    2525     */
    26     protected $version = '2.0.1';
     26    protected $version = '2.0.2';
    2727
    2828    /**
     
    7171    protected $requiredChars = 1800;
    7272   
    73    
    74    
    75    
     73
    7674    /**
    7775     * Initialize the plugin by setting localization, filters, and administration functions.
     
    8078     */
    8179    private function __construct() {
     80
     81        // Loads the plugin text domain for translation
     82        add_action( 'init', array( $this, 'wp_vgwort_load_plugin_textdomain' ) );
    8283
    8384        // Add the options page and menu item.
    8485        add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
    8586
    86         $this->vgWortMeta = get_option('wp_vgwortmetaname', 'wp_vgwortmarke');
    87 
    88         add_action( 'edit_user_profile' , array( &$this , 'add_profile_data' ));
    89         add_action( 'show_user_profile' , array( &$this , 'add_profile_data' ));
    90        
    91         add_action( 'personal_options_update', array( $this,'save_extra_user_profile_fields' ));
    92         add_action( 'edit_user_profile_update', array( $this,'save_extra_user_profile_fields' ));
    93        
    94         add_action( 'admin_footer' ,  array( $this , 'admin_footer' ));
    95        
    96         add_action( 'add_meta_boxes' , array( $this , 'add_custom_meta' ));
    97         add_action( 'save_post' , array( $this , 'save_post' ));
    98         add_action( 'the_content' , array( $this , 'frontend_display' ));
    99        
    100        
    101         add_filter( 'manage_posts_columns' , array( $this , 'column' ));
    102         add_filter( 'manage_pages_columns' , array( $this , 'column' ));
    103        
    104         add_action( 'manage_posts_custom_column' , array( $this , 'custom_column' ));
    105         add_action( 'manage_pages_custom_column' , array( $this , 'custom_column' ));
    106        
    107     }
    108 
     87        $this->vgWortMeta = get_option( 'wp_vgwortmetaname', 'wp_vgwortmarke' );
     88       
     89        add_action( 'edit_user_profile', array( &$this, 'add_profile_data' ) );
     90        add_action( 'show_user_profile', array( &$this, 'add_profile_data' ) );
     91       
     92        add_action( 'personal_options_update', array( $this,'save_extra_user_profile_fields' ) );
     93        add_action( 'edit_user_profile_update', array( $this,'save_extra_user_profile_fields' ) );
     94       
     95        add_action( 'admin_footer',  array( $this, 'admin_footer' ) );
     96       
     97        add_action( 'add_meta_boxes', array( $this, 'add_custom_meta' ) );
     98        add_action( 'save_post', array( $this, 'save_post' ) );
     99        add_action( 'the_content', array( $this, 'frontend_display' ) );
     100
     101        add_filter( 'manage_posts_columns', array( $this, 'column' ) );
     102        add_filter( 'manage_pages_columns', array( $this, 'column' ) );
     103       
     104        add_action( 'manage_posts_custom_column', array( $this, 'custom_column' ) );
     105        add_action( 'manage_pages_custom_column', array( $this, 'custom_column' ) );
     106       
     107    }
     108
     109    /**
     110     * Loads textdomain to translate
     111     *
     112     * @since 2.0.2
     113     */
     114    public function wp_vgwort_load_plugin_textdomain() {
     115
     116        load_plugin_textdomain( 'wp-vgwort-locale', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
     117
     118    }
    109119    /**
    110120     * Return an instance of this class.
     
    117127
    118128        // If the single instance hasn't been set, set it now.
    119         if ( null == self::$instance ) {
     129        if( null == self::$instance ) {
    120130            self::$instance = new self;
    121131        }
     
    133143        $this->plugin_screen_hook_suffix = add_submenu_page(
    134144            'options-general.php' ,
    135             'VG WORT',
    136             'VG WORT',
     145            __( 'VG WORT', 'wp-vgwort-locale' ),
     146            __( 'VG WORT', 'wp-vgwort-locale' ),
    137147            'add_users',
    138148            $this->plugin_slug,
     
    160170        global $post;
    161171
    162         if(!empty( $post->post_content )) {
    163         printf('<script language="javascript" type="text/javascript"> var div = document.getElementById("wp-word-count"); if (div != undefined) { div.innerHTML = div.innerHTML + \'%s\'; } </script>', str_replace("'", "\'", sprintf('<span class="inside"> / Zeichen:'.' %d'.'</span> ', $this->get_char_count( $post->post_title.$post->post_content ) )));
    164         }
    165     }
    166    
     172        if( ! empty( $post->post_content ) ) {
     173            printf( '<script language="javascript" type="text/javascript"> var div = document.getElementById("wp-word-count"); if (div != undefined) { div.innerHTML = div.innerHTML + \'%s\'; } </script>', str_replace( "'", "\'", sprintf( '<span class="inside"> / Zeichen:' . ' %d' . '</span> ', $this->get_char_count( $post->post_title . $post->post_content ) ) ) );
     174        }
     175    }
    167176   
    168177    /**
     
    172181    *
    173182    */
    174    
    175183    function column( $defaults )    {
    176184           
    177         $vgWortOptions = get_option('wp_vgwort_options');
     185        $vgWortOptions = get_option( 'wp_vgwort_options' );
    178186           
    179         if(!(isset($vgWortOptions['showChars']) AND !$vgWortOptions['showChars'])) {
     187        if( ! ( isset( $vgWortOptions['showChars'] ) AND ! $vgWortOptions['showChars'] ) ) {
    180188               
    181189            $currentPostType = get_post_type();
    182             $allowedTypes = get_option( 'wp_cpt',array('post','page'));
    183             if(in_array($currentPostType,$allowedTypes)){
     190            $allowedTypes = get_option( 'wp_cpt', array( 'post', 'page' ) );
     191            if( in_array( $currentPostType, $allowedTypes ) ) {
    184192                $defaults['vgwort'] = 'VG Wort';
    185193            }
     
    195203    *
    196204    */
    197    
    198205    function custom_column( $column ) {
    199206        global $post;
    200207
    201         if($column == 'vgwort') {
     208        if( $column == 'vgwort' ) {
    202209     
    203210            // is in Config?
    204            
    205             $vgWortOptions = get_option('wp_vgwort_options');
     211            $vgWortOptions = get_option( 'wp_vgwort_options' );
    206212                           
    207213            // Zeichen Anzeigen:
    208             if(!(isset($vgWortOptions['showChars']) AND !$vgWortOptions['showChars'])) {
     214            if( ! ( isset( $vgWortOptions['showChars'] ) AND ! $vgWortOptions['showChars'] ) ) {
    209215           
    210                 $charCount = $this->get_char_count( $post->post_title.$post->post_content );
     216                $charCount = $this->get_char_count( $post->post_title . $post->post_content );
    211217               
    212                 if($charCount > $this->requiredChars ){
     218                if( $charCount > $this->requiredChars ) {
    213219               
    214220                    // VG vorhanden?
    215              
    216                     $vgwort = get_post_meta( $post->ID , $this->vgWortMeta , true );
     221                    $vgwort = get_post_meta( $post->ID, $this->vgWortMeta, true );
    217222                 
    218                     if($vgwort) {
    219                         echo '<span style="color:green"> '.$charCount.' Zeichen - vorhanden</span>';
     223                    if( $vgwort ) {
     224                        echo '<span style="color:green">' . $charCount . ' ' . __( 'Zeichen - vorhanden', 'wp-vgwort-locale' ) . '</span>';
     225                    } else {
     226                      echo '<span style="color:red">' . $charCount . ' ' . __( 'Zeichen - nicht vorhanden', 'wp-vgwort-locale' ) . '</span>';
    220227                    }
    221                     else {
    222                       echo '<span style="color:red"> '.$charCount.' Zeichen - nicht vorhanden</span>';
    223                     }
    224                 }else{
    225                     echo '<span style="color:blue"> '.$charCount.' Zeichen - Limit nicht erreicht</span>';
     228                } else {
     229                    echo '<span style="color:blue">' . $charCount . ' ' . __( 'Zeichen - Limit nicht erreicht', 'wp-vgwort-locale' ) . '</span>';
    226230                }
    227231            }   
     
    235239    *
    236240    */
    237    
    238241    public function add_profile_data( $user ) {
    239242       
    240243        global $wpdb;
    241244
    242         if( user_can( $user->ID , 'edit_posts' ) ) {
    243 
    244             ?>
    245             <h3 id="vgwortanchor">VG Wort</h3>
     245        if( user_can( $user->ID, 'edit_posts' ) ) { ?>
     246            <h3 id="vgwortanchor"><?php _e( 'VG Wort', 'wp-vgwort-locale' ); ?></h3>
    246247            <table class="form-table">
    247             <tr>
    248             <th><label for="vgwort">bisher eingebunden Wortmarken: <?php echo $wpdb->get_var($wpdb->prepare("SELECT count(P.ID) as count FROM wp_postmeta PM INNER JOIN wp_posts P ON P.ID = PM.post_id WHERE PM.meta_key = 'wp_vgwortmarke' AND PM.meta_value != '' AND P.post_author = '%d'",$user->ID)); ?></label></th>
    249             <td>
    250                
    251             <?php
    252            
    253             $currentFilter = get_user_meta( $user->ID, 'wp-wort-filter', true);
    254            
    255             if(empty($currentFilter) OR $currentFilter == 'all'){
    256                 $currentFilter = "all";
    257                 $results = $wpdb->get_results($wpdb->prepare("SELECT * , CHAR_LENGTH(`post_content`) as charlength , post_type FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_type NOT IN ('attachment','nav_menu_item','revision') AND post_author = '%d' HAVING charlength > '%d'",$user->ID,$this->requiredChars));
    258             }else{
    259                 $results = $wpdb->get_results($wpdb->prepare("SELECT * , CHAR_LENGTH(`post_content`) as charlength , post_type FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_type = %s AND post_author = '%d' HAVING charlength > '%d'",$currentFilter,$user->ID,$this->requiredChars));
    260             }
    261 
    262             $postTypes = $wpdb->get_results("SELECT post_type  FROM ".$wpdb->posts." WHERE post_type NOT IN ('attachment','nav_menu_item','revision') group by post_type  ORDER BY FIELD(post_type,'post','page') DESC ");
    263        
    264             echo 'Filtern nach Posttype:<select name="wpvgwortcurrentposttype" size="1"><option value="all">Alle</option>';
    265        
    266             foreach($postTypes as $postType) {
    267            
    268                 if($postType->post_type != $currentFilter){
    269                     echo '<option value="'.$postType->post_type.'">'.$postType->post_type.'</option>';
    270                 }else{
    271                     echo '<option selected="selected" value="'.$postType->post_type.'">'.$postType->post_type.'</option>';
    272                 }
    273            
    274                
    275             }
    276             echo '</select><input type="submit" name="Sender" value="filtern" />';
    277            
    278             if(!empty($results)) {
    279            
    280             ?> 
    281                 <h4>Mögliche Beiträge</h4>
    282                 <table class="widefat">
    283                     <thead>
    284                     <tr>
    285                     <th>Titel</th>
    286                     <th>Anzahl zeichen</th>
    287                     <th>Type</th>
    288                     <th>Aktion</th>
    289                     </tr>
    290                     </thead>
    291                     <tfoot>
    292                     <tr>
    293                     <th>Titel</th>
    294                     <th>Anzahl zeichen</th>
    295                     <th>Type</th>
    296                     <th>Aktion</th>
    297                     </tr>
    298                     </tfoot>
    299                     <tbody>
    300                     <?php
    301                    
    302                     foreach($results as $result){
    303 
    304                         $vgwort = get_post_meta( $result->ID , $this->vgWortMeta , true );
    305                         if(empty($vgwort)){
    306                    
    307                             // Just Text nothing more :)
    308                             $clearContentCount = $this->get_char_count( $result->post_title.$result->post_content );
    309                             if($clearContentCount > $this->requiredChars){         
    310                                 echo '<tr><td>'.$result->post_title.'</td><td>'.$clearContentCount.'</td><td>'.$result->post_type.'</td><td><a href="'.get_admin_url().'post.php?post='.$result->ID.'&action=edit" title="jetzt VG Wort einfügen">Wortmarken einfügen</a></td></tr>';
    311 
     248                <tr>
     249                    <th>
     250                        <label for="vgwort"><?php _e( 'Bisher eingebunden Wortmarken', 'wp-vgwort-locale' ); ?>: <?php echo $wpdb->get_var( $wpdb->prepare("SELECT count(P.ID) as count FROM wp_postmeta PM INNER JOIN wp_posts P ON P.ID = PM.post_id WHERE PM.meta_key = 'wp_vgwortmarke' AND PM.meta_value != '' AND P.post_author = '%d'", $user->ID ) ); ?></label>
     251                    </th>
     252                    <td>
     253                        <?php
     254                        $currentFilter = get_user_meta( $user->ID, 'wp-wort-filter', true );
     255
     256                        if( empty( $currentFilter ) OR $currentFilter == 'all' ) {
     257                            $currentFilter = 'all';
     258                            $results = $wpdb->get_results( $wpdb->prepare( "SELECT * , CHAR_LENGTH(`post_content`) as charlength , post_type FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_type NOT IN ('attachment','nav_menu_item','revision') AND post_author = '%d' HAVING charlength > '%d'", $user->ID, $this->requiredChars ) );
     259                        } else {
     260                            $results = $wpdb->get_results( $wpdb->prepare( "SELECT * , CHAR_LENGTH(`post_content`) as charlength , post_type FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_type = %s AND post_author = '%d' HAVING charlength > '%d'", $currentFilter, $user->ID, $this->requiredChars ) );
     261                        }
     262
     263                        $postTypes = $wpdb->get_results( "SELECT post_type  FROM ".$wpdb->posts." WHERE post_type NOT IN ('attachment','nav_menu_item','revision') group by post_type  ORDER BY FIELD(post_type,'post','page') DESC ");
     264       
     265                        echo 'Filtern nach Posttype:<select name="wpvgwortcurrentposttype" size="1"><option value="all">' . __( 'Alle', 'wp-vgwort-locale' ) . '</option>';
     266       
     267                        foreach( $postTypes as $postType ) {
     268                            if( $postType->post_type != $currentFilter ) {
     269                                echo '<option value="'.$postType->post_type.'">'.$postType->post_type.'</option>';
     270                            } else {
     271                                echo '<option selected="selected" value="'.$postType->post_type.'">'.$postType->post_type.'</option>';
    312272                            }
    313273                        }
    314                     }
    315                    
    316                     ?>
    317                    
    318                     </tbody>
    319                     </table>
    320                 <?php
     274                        echo '</select><input type="submit" name="Sender" value="filtern" />';
    321275           
    322             }
    323         }
    324         ?>
    325            
    326         <span class="description">Diesen Beiträge sollten VG Wortmarken hinzugefügt werden</span>
    327         </td>
    328         </tr>
     276                        if( ! empty( $results ) ) { ?>
     277                            <h4><?php _e( 'Mögliche Beiträge', 'wp-vgwort-locale' ); ?></h4>
     278                            <table class="widefat">
     279                                <thead>
     280                                    <tr>
     281                                        <th><?php _e( 'Titel', 'wp-vgwort-locale' ); ?></th>
     282                                        <th><?php _e( 'Anzahl Zeichen', 'wp-vgwort-locale' ); ?></th>
     283                                        <th><?php _e( 'Type', 'wp-vgwort-locale' ); ?></th>
     284                                        <th><?php _e( 'Aktion', 'wp-vgwort-locale' ); ?></th>
     285                                    </tr>
     286                                </thead>
     287                                <tfoot>
     288                                    <tr>
     289                                        <th><?php _e( 'Titel', 'wp-vgwort-locale' ); ?></th>
     290                                        <th><?php _e( 'Anzahl Zeichen', 'wp-vgwort-locale' ); ?></th>
     291                                        <th><?php _e( 'Type', 'wp-vgwort-locale' ); ?></th>
     292                                        <th><?php _e( 'Aktion', 'wp-vgwort-locale' ); ?></th>
     293                                    </tr>
     294                                </tfoot>
     295                                <tbody>
     296                                    <?php foreach( $results as $result ) {
     297                                        $vgwort = get_post_meta( $result->ID, $this->vgWortMeta, true );
     298                                        if( empty( $vgwort ) ) {
     299                                            // Just Text nothing more :)
     300                                            $clearContentCount = $this->get_char_count( $result->post_title.$result->post_content );
     301                                            if( $clearContentCount > $this->requiredChars ) {
     302                                                echo '<tr>';
     303                                                    echo '<td>'.$result->post_title.'</td>';
     304                                                    echo '<td>'.$clearContentCount.'</td>';
     305                                                    echo '<td>'.$result->post_type.'</td>';
     306                                                    echo '<td>';
     307                                                        echo '<a href="' . get_admin_url() . 'post.php?post=' . $result->ID . '&action=edit" title="' . __( 'Jetzt VG Wort einfügen', 'wp-vgwort-locale' ) . '">';
     308                                                            echo __( 'Wortmarken einfügen', 'wp-vgwort-locale' );
     309                                                        echo '</a>';
     310                                                    echo '</td>';
     311                                                echo '</tr>';
     312                                            }
     313                                        }
     314                                    } ?>
     315                                </tbody>
     316                            </table>
     317                        <?php }
     318                    } ?>
     319                    <span class="description"><?php _e( 'Diesen Beiträge sollten VG Wortmarken hinzugefügt werden', 'wp-vgwort-locale' ); ?></span>
     320                </td>
     321            </tr>
    329322        </table>
    330        
    331 <?php }
     323    <?php }
    332324   
    333325    /**
     
    338330    *
    339331    */
    340 
    341332    public function save_extra_user_profile_fields( $user_id ) {
    342333 
    343         if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
     334        if( !current_user_can( 'edit_user', $user_id ) ) {
     335            return false;
     336        }
    344337         
    345338        update_user_meta( $user_id, 'wp-wort-filter', $_POST['wpvgwortcurrentposttype'] );
     
    353346    *
    354347    */
    355    
    356348    public function add_custom_meta() {
    357349        $currentPostType = get_post_type();
    358         $allowedTypes = get_option( 'wp_cpt',array('post','page'));
    359         if(in_array($currentPostType,$allowedTypes)){
    360             add_meta_box( 'CustomMeta', __( 'VG Wort', 'VG Wort' ), array( &$this , 'create_custom_meta' ), $currentPostType , 'advanced','high' );
     350        $allowedTypes = get_option( 'wp_cpt', array( 'post', 'page' ) );
     351        if( in_array( $currentPostType, $allowedTypes ) ) {
     352            add_meta_box( 'CustomMeta', __( 'VG Wort', 'wp-vgwort-locale' ), array( &$this, 'create_custom_meta' ), $currentPostType, 'side', 'high' );
    361353        }
    362354    }   
    363355   
    364 /**
    365     *
    366     * displays the metabox in Posts and pages
    367     * @param: object $post
    368     *
    369     */
     356    /**
     357     *
     358     * displays the metabox in Posts and pages
     359     * @param: object $post
     360     *
     361     */
    370362    public function create_custom_meta( $post ) {
    371363
    372364        // Use nonce for verification
    373         wp_nonce_field( plugin_basename(__FILE__) , $this->plugin_slug );
     365        wp_nonce_field( plugin_basename(__FILE__), $this->plugin_slug );
    374366
    375367        // The actual fields for data entry
    376         $marke = get_post_meta( $post->ID , $this->vgWortMeta , true );
    377        
    378         if(!empty($marke))
    379         {
    380             echo '<strong>Vorhandene Zählmarke</strong>: '.htmlspecialchars($marke);
     368        $marke = get_post_meta( $post->ID, $this->vgWortMeta, true );
     369       
     370        if( !empty( $marke ) ) {
     371            echo '<strong>' . __( 'Vorhandene Zählmarke', 'wp-vgwort-locale' ) . '</strong>: ' . htmlspecialchars( $marke );
    381372            echo '<input type="hidden" name="markein" value="1" />';
    382         }
    383        
    384         echo '<input type="input" size="150" name="wp_vgwortmarke" value="" />';
    385         echo '<input type="submit" name="Sender" value="speichern" /><br />';
    386         echo '<a href="http://www.vgwort.de/" target="_blank">VG WORT Marke erstellen</a>';
    387 
    388     }
    389    
    390 /**
    391     *
    392     * save the values of VGWort Meta
    393     * @param: int $post_id
    394     *
    395     */
    396    
     373        } ?>
     374        <input type="input" size="16" name="wp_vgwortmarke" id="wp_vgwortmarke" value="" class="form-input-tip" />
     375        <input type="submit" name="Sender" id="wp_vgwort_send_marker" value="<?php _e( 'speichern', 'wp-vgwort-locale' ); ?>" class="button" /><br />
     376        <a href="http://www.vgwort.de/" target="_blank" title="<?php _e( 'VG WORT Marke erstellen', 'wp-vgwort-locale' ); ?>"><?php _e( 'VG WORT Marke erstellen', 'wp-vgwort-locale' ); ?></a>
     377    <?php }
     378   
     379    /**
     380     *
     381     * save the values of VGWort Meta
     382     * @param: int $post_id
     383     *
     384     */
    397385    function save_post( $post_id ) {
    398    
    399         // Erweiterung bei Einstellungen 
    400         $allowedTypes = get_option( 'wp_cpt',array('post','page'));
    401    
     386
     387        // Erweiterung bei Einstellungen
     388        $allowedTypes = get_option( 'wp_cpt', array( 'post', 'page' ) );
     389
    402390        // AutoSave Methode
    403         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
     391        if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
    404392            return;
    405393        }
    406        
    407         if ( $post_object->post_type == 'revision' )
    408         return;
    409        
     394
     395        if( $post_object->post_type == 'revision' )
     396            return;
     397
    410398        // verify this came from the our screen and with proper authorization,
    411399        // because save_post can be triggered at other times
    412        
    413         if ( !wp_verify_nonce( $_POST[$this->plugin_slug], plugin_basename( __FILE__ ) ) )
    414         return;
     400        if( !wp_verify_nonce( $_POST[$this->plugin_slug], plugin_basename( __FILE__ ) ) )
     401            return;
    415402
    416403        // Check permissions
    417 
    418         if ( in_array(esc_attr($_POST['post_type']),$allowedTypes)) {
    419             if ( !current_user_can( 'edit_page', $post_id ) ) {
     404        if( in_array( esc_attr( $_POST['post_type'] ), $allowedTypes ) ) {
     405            if( !current_user_can( 'edit_page', $post_id ) ) {
    420406                return;
    421             }   
    422            
    423         }
    424         else{
    425            
    426             return;
    427         }
    428        
    429         // vars übergeben
    430    
    431         $markeIn = sanitize_text_field($_POST['markein']);
    432         $vgWortMarke = $_POST['wp_vgwortmarke'];
    433        
    434         if(!isset($markeIn)){
    435        
    436             if(!empty($vgWortMarke)){
    437                 update_post_meta($post_id , $this->vgWortMeta , $vgWortMarke );
    438             }else{
    439                 delete_post_meta($post_id , $this->vgWortMeta , $vgWortMarke);
    440407            }
    441408        } else {
    442 
    443             if(!empty($_POST['wp_vgwortmarke'])){
    444                 update_post_meta($post_id , $this->vgWortMeta , $vgWortMarke );
     409            return;
     410        }
     411
     412        // vars übergeben
     413        $markeIn = sanitize_text_field( $_POST['markein'] );
     414        $vgWortMarke = $_POST['wp_vgwortmarke'];
     415
     416        if( ! isset( $markeIn ) ) {
     417            if( !empty( $vgWortMarke ) ) {
     418                update_post_meta( $post_id, $this->vgWortMeta, $vgWortMarke );
     419            } else {
     420                delete_post_meta( $post_id, $this->vgWortMeta, $vgWortMarke );
    445421            }
    446         }
    447    
    448     }
    449    
    450         /**
    451     *
    452     * Calculate the Chars of the delivered content
    453     * @param: string $content
    454     * @return int
    455     *
    456     */
    457 
     422        } else {
     423            if( ! empty( $_POST['wp_vgwortmarke'] ) ) {
     424                update_post_meta( $post_id, $this->vgWortMeta, $vgWortMarke );
     425            }
     426        }
     427
     428    }
     429   
     430    /**
     431     *
     432     * Calculate the Chars of the delivered content
     433     * @param: string $content
     434     * @return int
     435     *
     436    **/
    458437    private function get_char_count( $content ) {
    459         return mb_strlen(preg_replace("/\\015\\012|\\015|\\012| {2,}|\[[a-zA-Z0-9\_=\"\'\. \/]*\]/", "", strip_tags(html_entity_decode($content ))));
    460     }
    461        
    462 /**
    463     *
    464     * append the Value of $this->vgWortMeta on the end of content
    465     * just insert $this->vgWortMeta on page.php and single.php
    466     * @param: string $content
    467     * @return string $content
    468     *
    469     */
    470    
     438        return mb_strlen( preg_replace("/\\015\\012|\\015|\\012| {2,}|\[[a-zA-Z0-9\_=\"\'\. \/]*\]/", "", strip_tags( html_entity_decode( $content ) ) ) );
     439    }
     440       
     441    /**
     442     *
     443     * append the Value of $this->vgWortMeta on the end of content
     444     * just insert $this->vgWortMeta on page.php and single.php
     445     * @param: string $content
     446     * @return string $content
     447     *
     448     */
    471449    public function frontend_display( $content ) {
    472450
    473         global $post; 
    474    
    475         $vgwort = get_post_meta( $post->ID , $this->vgWortMeta , true );
    476        
    477         if(is_single() OR is_page()){
    478             if(!empty( $vgwort )){
     451        global $post;
     452
     453        $vgwort = get_post_meta( $post->ID, $this->vgWortMeta, true );
     454
     455        if( is_single() OR is_page() ) {
     456            if( ! empty( $vgwort ) ) {
    479457                $content .= $vgwort;
    480458            }
    481459        }
    482    
     460
    483461        return $content;
    484462    }
    485    
    486     public function get_vg_wort_meta(){
     463
     464    public function get_vg_wort_meta() {
    487465        return $this->vgWortMeta;
    488466    }
  • wp-vgwort/trunk/export.php

    r728901 r734295  
    1 <?php
    2    
    3     header("content-type: text/csv");
    4     header("content-disposition: attachment; filename=\"export.csv\"");
     1<?php
     2header("content-type: text/csv");
     3header("content-disposition: attachment; filename=\"export.csv\"");
    54
    6     if(file_exists($_SERVER["DOCUMENT_ROOT"].'wp-blog-header.php')){
    7         include_once($_SERVER["DOCUMENT_ROOT"].'wp-blog-header.php');
     5if( file_exists( $_SERVER["DOCUMENT_ROOT"] . 'wp-blog-header.php' ) ) {
     6    include_once( $_SERVER["DOCUMENT_ROOT"] . 'wp-blog-header.php' );
     7}
     8
     9if( file_exists( $_SERVER["DOCUMENT_ROOT"] . '/wp-blog-header.php' ) ) {
     10    include_once( $_SERVER["DOCUMENT_ROOT"] . '/wp-blog-header.php' );
     11}
     12
     13global $current_user;
     14get_currentuserinfo();
     15
     16$accessArray = array( 'administrator' );
     17if( in_array ( $current_user->roles[0], $accessArray ) ) {
     18
     19    $doAction = $_GET['action'];
     20    if( isset( $_POST['action'] ) )
     21        $doAction = $_POST['action'];
     22
     23    switch( $doAction ) {
     24
     25        case"export":
     26
     27            global $wpdb;
     28
     29            $exportDocument = '';
     30            $exportResult = $wpdb->get_results( $wpdb->prepare( 'SELECT WPP.ID , WPP.post_title, WPPM.meta_value  FROM ' . $wpdb->posts . ' WPP INNER JOIN ' . $wpdb->postmeta . ' WPPM ON WPP.ID = WPPM.post_id WHERE WPPM.meta_key  = %s', WP_VGWORT::get_instance()->get_vg_wort_meta() ), ARRAY_A );
     31            foreach( $exportResult as &$result ) {
     32                $result['link'] = get_permalink( $result['ID'] );
     33                $exportDocument .= implode( ";", $result ) . "\n";
     34            }
     35
     36            echo $exportDocument;
     37
     38            break;
    839    }
    9    
    10     if(file_exists($_SERVER["DOCUMENT_ROOT"].'/wp-blog-header.php')){
    11         include_once($_SERVER["DOCUMENT_ROOT"].'/wp-blog-header.php');
    12     }
    13 
    14     global $current_user;
    15     get_currentuserinfo();
    16    
    17     $accessArray = array('administrator');
    18     if(in_array($current_user->roles[0],$accessArray)){
    19    
    20         $doAction = $_GET['action'];
    21         if(isset($_POST['action'])) $doAction = $_POST['action'];
    22         switch($doAction){
    23            
    24             case"export":
    25                            
    26                 global $wpdb;
    27    
    28                     $exportDocument = "";
    29                     $exportResult = $wpdb->get_results($wpdb->prepare('SELECT WPP.ID , WPP.post_title, WPPM.meta_value  FROM ' . $wpdb->posts . ' WPP INNER JOIN ' . $wpdb->postmeta . ' WPPM ON WPP.ID = WPPM.post_id WHERE WPPM.meta_key  = %s',WP_VGWORT::get_instance()->get_vg_wort_meta()),ARRAY_A);
    30                     foreach($exportResult as &$result){
    31 
    32                         $result['link'] = get_permalink($result['ID']);
    33                         $exportDocument .= implode(";",$result)."\n";
    34                     }
    35            
    36                 echo $exportDocument;
    37            
    38             break;
    39        
    40        
    41         }
    42     }
    43 
    44 
    45 ?>
     40}
  • wp-vgwort/trunk/readme.txt

    r733723 r734295  
    55Requires at least: 3.0
    66Tested up to: 3.5
    7 Stable tag: 2.0.1
     7Stable tag: 2.0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4141
    4242== Changelog ==
     43
     44= 2.0.2 =
     45* Bugfix
     46* better codestyte
     47* Multi-Language
    4348
    4449= 2.0.1 =
  • wp-vgwort/trunk/views/admin.php

    r728901 r734295  
    1313 */
    1414
    15     $action = sanitize_text_field( $_POST['action'] );
    16        
    17     if(isset( $action )) {
    18    
    19         switch($action){
    20    
     15$action = sanitize_text_field( $_POST['action'] );
     16       
     17if( isset( $action ) ) {
     18
     19    switch( $action ){
     20
    2121        case"save":
    22            
    23             if(isset($_POST['cpt'])) {
    24                 $ctypes = array('post','page');
    25                 foreach($_POST['cpt'] as $key => $value){
     22
     23            if( isset( $_POST['cpt'] ) ) {
     24                $ctypes = array( 'post', 'page' );
     25                foreach( $_POST['cpt'] as $key => $value ){
    2626                    $ctypes[] = sanitize_title( $key );
    2727                }
    28                
    29                 update_option('wp_cpt' , $ctypes,array());
    30                
    31             }   
    32 
    33             $this->vgWortMeta = esc_html($_POST['wp_vgwort_meta']);
    34            
     28                update_option( 'wp_cpt', $ctypes, array() );
     29            } elseif( is_null( $_POST['cpt'] ) ) {
     30                // None of the CPT are selected. reset the option.
     31                $wp_cpt_old = get_option( 'wp_cpt' );
     32                update_option( 'wp_cpt', array( 'post', 'page' ), $wp_cpt_old );
     33            }
     34
     35            $this->vgWortMeta = esc_html( $_POST['wp_vgwort_meta'] );
     36
    3537            $vgWortOptions = array(
    36                 'showChars' => esc_attr($_POST['showchars'])
    37                
     38                'showChars' => esc_attr( $_POST['showchars'] )
    3839            );
    39            
    40             update_option('wp_vgwort_options' , $vgWortOptions);
    41             update_option('wp_vgwortmetaname' , $this->vgWortMeta);
    42            
     40
     41            update_option( 'wp_vgwort_options', $vgWortOptions );
     42            update_option( 'wp_vgwortmetaname', $this->vgWortMeta );
     43
    4344        break;
    44         }
    45        
    4645    }
    47        
    48     $this->vgWortMetaOption = get_option( 'wp_vgwortmetaname' , 'wp_vgwortmarke' );
     46
     47}
     48       
     49$this->vgWortMetaOption = get_option( 'wp_vgwortmetaname', 'wp_vgwortmarke' );
    4950   
    50     $vgWortOptions = get_option('wp_vgwort_options');
    51        
    52     ?>
    53     <div class="wrap">
    54 
     51$vgWortOptions = get_option( 'wp_vgwort_options' );
     52       
     53?>
     54<div class="wrap">
    5555    <?php screen_icon(); ?>
    5656    <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
    5757
    58        
    59         <?php $section = sanitize_text_field( $_GET['section'] ); ?>
    60    
    61    
     58    <?php $section = sanitize_text_field( $_GET['section'] ); ?>
     59
    6260    <h2 class="nav-tab-wrapper">
    63         <a href="<?php echo admin_url('options-general.php?page='.$this->plugin_slug); ?>" class="nav-tab <?php if(empty($section)) { echo 'nav-tab-active'; } ?>">
    64             Konfiguration
    65         </a>
    66         <a href="<?php echo admin_url('options-general.php?page='.$this->plugin_slug.'&section=export'); ?>" class="nav-tab <?php if($section == 'export') { echo 'nav-tab-active'; } ?>">
    67           Export             
    68         </a>
    69         <a href="<?php echo admin_url('options-general.php?page='.$this->plugin_slug.'&section=misc'); ?>" class="nav-tab <?php if($section == 'misc') { echo 'nav-tab-active'; } ?>">
    70           Allgemein         
    71         </a>
    72         <a href="<?php echo admin_url('options-general.php?page='.$this->plugin_slug.'&section=overview'); ?>" class="nav-tab <?php if($section == 'overview') { echo 'nav-tab-active'; } ?>">
    73           Übersicht       
    74         </a>
    75         <a href="<?php echo admin_url('options-general.php?page='.$this->plugin_slug.'&section=posts'); ?>" class="nav-tab <?php if($section == 'posts') { echo 'nav-tab-active'; } ?>">
    76           Beiträge       
     61        <a href="<?php echo admin_url( 'options-general.php?page=' . $this->plugin_slug ); ?>" class="nav-tab <?php if( empty( $section ) ) { echo 'nav-tab-active'; } ?>">
     62            <?php _e( 'Konfiguration', 'wp-vgwort-locale' ); ?>
     63        </a>
     64        <a href="<?php echo admin_url( 'options-general.php?page=' . $this->plugin_slug . '&section=export' ); ?>" class="nav-tab <?php if( $section == 'export' ) { echo 'nav-tab-active'; } ?>">
     65          <?php _e( 'Export', 'wp-vgwort-locale' ); ?>
     66        </a>
     67        <a href="<?php echo admin_url( 'options-general.php?page=' . $this->plugin_slug . '&section=misc' ); ?>" class="nav-tab <?php if( $section == 'misc' ) { echo 'nav-tab-active'; } ?>">
     68          <?php _e( 'Allgemein', 'wp-vgwort-locale' ); ?>
     69        </a>
     70        <a href="<?php echo admin_url( 'options-general.php?page=' . $this->plugin_slug . '&section=overview' ); ?>" class="nav-tab <?php if( $section == 'overview' ) { echo 'nav-tab-active'; } ?>">
     71          <?php _e( 'Übersicht', 'wp-vgwort-locale' ); ?>
     72        </a>
     73        <a href="<?php echo admin_url( 'options-general.php?page=' . $this->plugin_slug . '&section=posts' ); ?>" class="nav-tab <?php if( $section == 'posts' ) { echo 'nav-tab-active'; } ?>">
     74          <?php _e( 'Beiträge', 'wp-vgwort-locale' ); ?>
    7775        </a>
    7876    </h2>
    79        
    80        
    81     <?php switch($section){
     77
     78    <?php switch( $section ) {
    8279   
    8380        case "posts":
    8481       
    85         global $wpdb;
    86         $results = $wpdb->get_results($wpdb->prepare("SELECT * , CHAR_LENGTH(`post_content`) as charlength , post_type FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_type NOT IN ('attachment','nav_menu_item','revison') HAVING charlength > '%d'",$this->requiredChars));
    87        
    88     ?>
     82            global $wpdb;
     83            $results = $wpdb->get_results(
     84                $wpdb->prepare(
     85                    "SELECT * , CHAR_LENGTH(`post_content`) as charlength , post_type FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_type NOT IN ('attachment','nav_menu_item','revison') HAVING charlength > '%d'",
     86                    $this->requiredChars
     87                )
     88            );
     89            ?>
    8990   
    90     <h3>Hier können Wortmarken eingefügt werden:</h3>
     91            <h3><?php _e( 'Hier können Wortmarken eingefügt werden', 'wp-vgwort-locale' ); ?>:</h3>
    9192   
    92     <table class="widefat">
    93                     <thead>
     93            <table class="widefat">
     94                <thead>
    9495                    <tr>
    95                     <th>Titel</th>
    96                     <th>Anzahl zeichen</th>
    97                     <th>Type</th>
    98                     <th>Aktion</th>
    99                     </tr>
    100                     </thead>
    101                     <tfoot>
     96                        <th><?php _e( 'Titel', 'wp-vgwort-locale' ); ?></th>
     97                        <th><?php _e( 'Anzahl Zeichen', 'wp-vgwort-locale' ); ?></th>
     98                        <th><?php _e( 'Type', 'wp-vgwort-locale' ); ?></th>
     99                        <th><?php _e( 'Aktion', 'wp-vgwort-locale' ); ?></th>
     100                    </tr>
     101                </thead>
     102                <tfoot>
    102103                    <tr>
    103                     <th>Titel</th>
    104                     <th>Anzahl zeichen</th>
    105                     <th>Type</th>
    106                     <th>Aktion</th>
    107                     </tr>
    108                     </tfoot>
    109                     <tbody>
    110                     <?php
    111                    
    112                     foreach($results as $result){
    113 
    114                         $vgwort = get_post_meta( $result->ID , $this->vgWortMeta , true );
    115                         if(empty($vgwort)){
    116                    
     104                        <th><?php _e( 'Titel', 'wp-vgwort-locale' ); ?></th>
     105                        <th><?php _e( 'Anzahl Zeichen', 'wp-vgwort-locale' ); ?></th>
     106                        <th><?php _e( 'Type', 'wp-vgwort-locale' ); ?></th>
     107                        <th><?php _e( 'Aktion', 'wp-vgwort-locale' ); ?></th>
     108                    </tr>
     109                </tfoot>
     110                <tbody>
     111                    <?php foreach( $results as $result ) {
     112                        $vgwort = get_post_meta( $result->ID, $this->vgWortMeta, true );
     113                        if( empty( $vgwort ) ) {
    117114                            // Just Text nothing more :)
    118                             $clearContentCount = $this->get_char_count( $result->post_title.$result->post_content );
    119                             if($clearContentCount > $this->requiredChars){         
    120                                 echo '<tr><td>'.$result->post_title.'</td><td>'.$clearContentCount.'</td><td>'.$result->post_type.'</td><td><a href="'.get_admin_url().'post.php?post='.$result->ID.'&action=edit" title="jetzt VG Wort einfügen">Wortmarken einfügen</a></td></tr>';
    121 
     115                            $clearContentCount = $this->get_char_count( $result->post_title . $result->post_content );
     116                            if( $clearContentCount > $this->requiredChars ) {
     117                                echo '<tr>';
     118                                    echo '<td>'.$result->post_title.'</td>';
     119                                    echo '<td>'.$clearContentCount.'</td>';
     120                                    echo '<td>'.$result->post_type.'</td>';
     121                                    echo '<td>';
     122                                        echo '<a href="'.get_admin_url().'post.php?post='.$result->ID.'&action=edit" title="' . __( 'Jetzt VG Wort einfügen', 'wp-vgwort-locale' ) . '">';
     123                                            echo __( 'Wortmarken einfügen', 'wp-vgwort-locale' );
     124                                        echo '</a>';
     125                                    echo '</td>';
     126                                echo '</tr>';
    122127                            }
    123128                        }
    124                     }
    125                                        
    126                     ?>
    127                    
    128                     </tbody>
    129                     </table>
    130    
    131         <?php
    132         break;
    133    
    134         case "export":
    135         ?>
     129                    } ?>
     130                </tbody>
     131            </table>
     132
     133            <?php break;
     134
     135        case "export": ?>
    136136       
    137137            <table>
    138138                <tr valign="top">
    139                 <th scope="row"> <h3>VG Wort Marken Export:</h3> </th>
    140                 <td>
    141                    
    142                 </td>
     139                    <th scope="row"><h3><?php _e( 'VG Wort Marken Export', 'wp-vgwort-locale' ); ?>:</h3></th>
     140                    <td></td>
    143141                </tr>
    144                
    145142                <tr>
    146                 <td>
    147                
    148                 </td>
    149                 <td>
    150                    
    151                     <p>Die Export Funktion dient zur Ausgabe der genutzten VG Wort Marken in eine CSV.<br /> Diese Datei kann mit einen Tabellen Programm wie Excel geöffnet werden.</p>
    152                         <form action="<?php echo sprintf('%s?action=%s&amp;noheader=true',plugins_url( $this->plugin_name.'/export.php' , dirname(__FILE__) ),'export'); ?>" method="POST">
    153                         <input type="hidden" name="action" value="export" />
    154                         <input type="submit" name="export" value="exportieren" class="button-primary" />
    155                                
    156                     </form>
    157                 </td>
     143                    <td></td>
     144                    <td>
     145                        <p>
     146                            <?php _e( 'Die Export Funktion dient zur Ausgabe der genutzten VG Wort Marken in eine CSV.', 'wp-vgwort-locale' ); ?><br />
     147                            <?php _e( 'Diese Datei kann mit einen Tabellen Programm wie Excel geöffnet werden.', 'wp-vgwort-locale' ); ?>
     148                        </p>
     149                        <form action="<?php echo sprintf( '%s?action=%s&amp;noheader=true', plugins_url( $this->plugin_name . '/export.php', dirname(__FILE__) ), 'export' ); ?>" method="POST">
     150                            <input type="hidden" name="action" value="export" />
     151                            <input type="submit" name="export" value="<?php _e( 'exportieren', 'wp-vgwort-locale' ); ?>" class="button-primary" />
     152                        </form>
     153                    </td>
    158154                </tr>
    159155            </table>
     156
     157            <?php
     158            break;
     159
     160        case"misc": ?>
     161            <table>
     162                <tr valign="top">
     163                    <th scope="row"><h3><?php _e( 'Fehler und Bugs', 'wp-vgwort-locale' ); ?>:</h3></th>
     164                    <td>
     165                        <p>
     166                            <?php _e( 'Wenn Fehler Ihr Fehler in unserem Plugin gefunden habt, dann wäre es sehr nett wenn Ihr uns diese mitteilt.', 'wp-vgwort-locale' ); ?><br />
     167                            <?php _e( 'Dazu könnt Ihr auf unserer Plugin Seite kommentieren oder eine E-Mail an uns senden.', 'wp-vgwort-locale' ); ?>
     168                        </p>
     169                        <ul>
     170                            <li>
     171                                <?php _e( 'Kontakt', 'wp-vgwort-locale' ); ?>
     172                            </li>
     173                            <li>
     174                                <a href="http://www.mywebcheck.de/vg-wort-plugin-wordpress/" title="MyWebcheck - <?php _e( 'Plugin Seite', 'wp-vgwort-locale' ); ?>" target="_blank">
     175                                    <?php _e( 'Plugin Seite', 'wp-vgwort-locale' ); ?>
     176                                </a>
     177                            </li>
     178                            <li>
     179                                <a href="mailto:[email protected]" title="<?php _e( 'Schreib mir eine Mail', 'wp-vgwort-locale' ); ?>">[email protected]</a>
     180                            </li>
     181                        </ul>
     182                    </td>
     183                </tr>
     184                <tr valign="top">
     185                    <th scope="row"><h3><?php _e( 'Cooles Plugin?', 'wp-vgwort-locale' ); ?>:</h3></th>
     186                    <td>
     187                        <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
     188                        <input type="hidden" name="cmd" value="_s-xclick">
     189                        <input type="hidden" name="hosted_button_id" value="2PJGA2XSNG8EQ">
     190                        <input
     191                            type="image"
     192                            src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donateCC_LG.gif"
     193                            border="0"
     194                            name="submit"
     195                            alt="<?php _e( 'Jetzt einfach, schnell und sicher online bezahlen – mit PayPal.', 'wp-vgwort-locale' ); ?>"
     196                        >
     197                        <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
     198                        </form>
     199                    </td>
     200                </tr>
     201            </table>
     202
     203            <?php
     204            break;
     205
     206        case"overview": ?>
    160207           
    161         <?php
    162         break;
    163        
    164         case"misc":
    165         ?>
    166             <table>
    167             <tr valign="top">
    168             <th scope="row"> <h3>Fehler und Bugs:</h3> </th>
    169             <td>
    170                
    171                 <br />
    172                 <br />
    173                 <br />
    174            
    175                 Wenn Fehler Ihr Fehler in unserem Plugin gefunden habt, dann wäre es sehr nett wenn Ihr uns diese mitteilt.<br />
    176                 Dazu könnt Ihr auf unserer Plugin Seite kommentieren oder eine E-Mail an uns senden.
    177                
    178                 <ul>
    179                     <li>Kontakt</li>
    180                     <li><a href="http://www.mywebcheck.de/vg-wort-plugin-wordpress/" title="MyWebcheck - Plugin Seite" target="_blank">Plugin Seite</a></li>
    181                     <li><a href="[email protected]">[email protected]</li>
    182                 </ul>
    183                
    184             </td>
    185             </tr>
    186             <tr valign="top">
    187             <th scope="row"> <h3>Cooles Plugin?:</h3> </th>
    188             <td>
    189                 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    190                 <input type="hidden" name="cmd" value="_s-xclick">
    191                 <input type="hidden" name="hosted_button_id" value="2PJGA2XSNG8EQ">
    192                 <input type="image" src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal.">
    193                 <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
    194                 </form>
    195             </td>
    196             </tr>
     208            <?php
     209            global $wpdb;
     210
     211            $exportDocument = "";
     212            $exportResult = $wpdb->get_results( $wpdb->prepare( 'SELECT WPP.ID , WPP.post_title, WPPM.meta_value  FROM ' . $wpdb->posts . ' WPP INNER JOIN ' . $wpdb->postmeta . ' WPPM ON WPP.ID = WPPM.post_id WHERE WPPM.meta_key  = %s', $this->vgWortMeta ), ARRAY_A );
     213
     214            ?>
     215
     216            <table class="widefat">
     217                <thead>
     218                    <tr>
     219                        <th><?php _e( 'ID', 'wp-vgwort-locale' ); ?></th>
     220                        <th><?php _e( 'Titel', 'wp-vgwort-locale' ); ?></th>
     221                        <th><?php _e( 'Url', 'wp-vgwort-locale' ); ?></th>
     222                        <th><?php _e( 'Wortmarke', 'wp-vgwort-locale' ); ?></th>
     223                    </tr>
     224                </thead>
     225                <tfoot>
     226                    <tr>
     227                        <th><?php _e( 'ID', 'wp-vgwort-locale' ); ?></th>
     228                        <th><?php _e( 'Titel', 'wp-vgwort-locale' ); ?></th>
     229                        <th><?php _e( 'Url', 'wp-vgwort-locale' ); ?></th>
     230                        <th><?php _e( 'Wortmarke', 'wp-vgwort-locale' ); ?></th>
     231                    </tr>
     232                </tfoot>
     233                <tbody>
     234                    <?php
     235                    foreach( $exportResult as &$result ) {
     236                        echo '<tr>';
     237                            echo '<td>'.$result['ID'].'</td>';
     238                            echo '<td>'.$result['post_title'].'</td>';
     239                            echo '<td>'.get_permalink( $result['ID'] ).'</td>';
     240                            echo '<td>'.htmlspecialchars( $result['meta_value'] ).'</td>';
     241                        echo '</tr>';
     242                    }
     243                    ?>
     244                </tbody>
    197245            </table>
    198        
    199         <?php
    200         break;
    201        
    202         case"overview":
    203         ?>
    204            
    205         <?php
    206        
    207         global $wpdb;
    208        
    209         $exportDocument = "";
    210             $exportResult = $wpdb->get_results($wpdb->prepare('SELECT WPP.ID , WPP.post_title, WPPM.meta_value  FROM ' . $wpdb->posts . ' WPP INNER JOIN ' . $wpdb->postmeta . ' WPPM ON WPP.ID = WPPM.post_id WHERE WPPM.meta_key  = %s',$this->vgWortMeta),ARRAY_A);
    211            
    212             ?>
    213            
    214             <table class="widefat">
    215             <thead>
    216             <tr>
    217             <th>ID</th>
    218             <th>Titel</th>
    219             <th>Url</th>
    220             <th>Wortmarke</th>
    221             </tr>
    222             </thead>
    223             <tfoot>
    224             <tr>
    225             <th>ID</th>
    226             <th>Titel</th>
    227             <th>Url</th>
    228             <th>Wortmarke</th>
    229             </tr>
    230             </tfoot>
    231             <tbody>
     246
    232247            <?php
    233            
    234             foreach($exportResult as &$result){
    235                
    236                 echo '<tr><td>'.$result['ID'].'</td><td>'.$result['post_title'].'</td><td>'.get_permalink($result['ID']).'</td><td>'.htmlspecialchars($result['meta_value']).'</td></tr>';
    237 
    238             }
    239            
    240             ?>
    241            
    242             </tbody>
    243             </table>
    244            
    245             <?php
    246         break;
    247        
    248         default:
    249             ?>
     248            break;
     249       
     250        default: ?>
    250251            <form method="POST" action="">
    251                 <h2>Einstellungen VG-Wort Plugin</h2>
    252                
    253             <table class="form-table">
    254             <tr valign="top">
    255             <th scope="row"> <h3>Konfiguration:</h3> </th>
    256             <td>
    257            
    258                 <?php
    259 
    260                 $types = get_post_types( array('public' => true,'show_ui' => true,'_builtin' => false) );
    261                 $myTypes = get_option( 'wp_cpt');
    262                
    263                 echo '<h4>Custom Post Types</h4>';
    264                 echo'<p>Markierte Custom Post Types werden mit der VG Wort Funktion versehen</p>';
    265                
    266                 if(count($types)>0){
    267                
    268                     echo '<ul>';
    269                     foreach($types as $type){
    270                         if(in_array($type,$myTypes)){
    271                             echo '<li><input checked="checked" type="checkbox" name="cpt['.$type.']"> '.$type.' </li>';
    272                         } else {
    273                             echo '<li><input type="checkbox" name="cpt['.$type.']"> '.$type.' </li>';
    274                         }
    275                     }
    276                    
    277                     echo '</ul>';
    278                 }
    279                 else {
    280                     echo '<strong>Keine anderen Typen vorhanden!</strong>';
    281                 }
    282                
    283                
    284                 ?>
    285                 <br />
    286                 <br />
    287                 <span class="description">In Beiträge und Seiten sind immer vorhanden!</span>
    288                 <br />
    289                 <br />
    290             </td>
    291             </tr>
    292             <tr valign="top">
    293             <th scope="row"> <h3>MetaName:</h3> </th>
    294             <td>
    295                 <input size="25" name="wp_vgwort_meta" value="<?php echo $this->vgWortMeta; ?>" /><br /><br />
    296                 <span class="description">Dieses Feld kann genutzt werden um ein kompatible Lösung für andere Plugins zu erhalten</span>
    297                 <ul>
    298                     <li>Default: "wp_vgworkmarke"</li>
    299                     <li><a href="http://maheo.eu/355-vg-wort-plugin-fuer-wordpress.php" title="VG Wort Plugin - Heiner Otterstedt" target="_blank">VG-Wort Krimskram</a>  -> "vgwpixel"</li>
    300                 </ul>
    301                
    302             </td>
    303             </tr>
    304             <tr valign="top">
    305             <th scope="row"> <h3>Zeichen anzeigen:</h3> </th>
    306             <td>
    307                 <?php
    308                
    309                 $showCharsInOverview = true;
    310                
    311                 // Zeichen Anzeigen:
    312                 if(isset($vgWortOptions['showChars'])) {
    313                     if($vgWortOptions['showChars']!='') {
    314                         $showCharsInOverview = $vgWortOptions['showChars'];
    315                     }
    316                 }
    317                
    318                 ?>
    319                 <span class="description">Soll in den ausgewählten Beiträgen die Zeichen Anzahl angezeigt werden?</span>
    320                 <br />
    321                 <?php if($showCharsInOverview){  ?>
    322                 <input type="radio" name="showchars" value="0" /> Nein<br />
    323                 <input type="radio" name="showchars" checked="checked" value="1" /> Ja
    324                 <br/>
    325                 <?php } else { ?>
    326                 <input type="radio" name="showchars" checked="checked" value="0" /> Nein<br />
    327                 <input type="radio" name="showchars" value="1" /> Ja
    328                 <br/>
    329                 <?php } ?>
    330             </td>
    331             </tr>
    332             <tr valign="top">
    333             <th scope="row"> <h3>Speichern:</h3> </th>
    334             <td>
    335                 <input type="hidden" name="action" value="save" />
    336                 <input type="submit" name="save" value="Einstellung speichern" class="button-primary" / >
    337             </td>
    338             </tr>
    339             </table>
    340            
     252                <h2><?php _e( 'Einstellungen VG-Wort Plugin', 'wp-vgwort-locale' ); ?></h2>
     253                <table class="form-table">
     254                    <tr valign="top">
     255                        <th scope="row">
     256                            <h3><?php _e( 'Konfiguration', 'wp-vgwort-locale' ); ?>:</h3>
     257                        </th>
     258                        <td>
     259                            <?php
     260                            $types = get_post_types( array( 'public' => true, 'show_ui' => true, '_builtin' => false ) );
     261                            $myTypes = get_option( 'wp_cpt' );
     262
     263                            echo '<h4>' . __( 'Custom Post Types', 'wp-vgwort-locale' ) . '</h4>';
     264                            echo'<p>' . __( 'Markierte Custom Post Types werden mit der VG Wort Funktion versehen', 'wp-vgwort-locale' ) . '</p>';
     265
     266                            if( count( $types ) > 0 ) {
     267                                echo '<ul>';
     268                                    foreach( $types as $type ) {
     269                                        if( $myTypes ) {
     270                                            if( in_array( $type, $myTypes ) ) {
     271                                                echo '<li><input checked="checked" type="checkbox" name="cpt['.$type.']"> '.$type.' </li>';
     272                                            } else {
     273                                                echo '<li><input type="checkbox" name="cpt['.$type.']"> '.$type.' </li>';
     274                                            }
     275                                        } else {
     276                                            echo '<li><input type="checkbox" name="cpt['.$type.']"> '.$type.' </li>';
     277                                        }
     278
     279                                    }
     280                                echo '</ul>';
     281                            } else {
     282                                echo '<strong>' . __( 'Keine anderen Typen vorhanden!', 'wp-vgwort-locale' ) . '</strong>';
     283                            } ?>
     284                            <p>
     285                                <span class="description"><?php _e( 'In Beiträge und Seiten sind immer vorhanden!', 'wp-vgwort-locale' ); ?></span>
     286                            </p>
     287                        </td>
     288                    </tr>
     289                    <tr valign="top">
     290                        <th scope="row"><h3><?php _e( 'MetaName', 'wp-vgwort-locale' ); ?>:</h3></th>
     291                        <td>
     292                            <input size="25" name="wp_vgwort_meta" value="<?php echo $this->vgWortMeta; ?>" /><br /><br />
     293                            <span class="description"><?php _e( 'Dieses Feld kann genutzt werden um ein kompatible Lösung für andere Plugins zu erhalten', 'wp-vgwort-locale' ); ?></span>
     294                            <ul>
     295                                <li><?php _e( 'Default', 'wp-vgwort-locale' ); ?>: "wp_vgworkmarke"</li>
     296                                <li>
     297                                    <a href="http://maheo.eu/355-vg-wort-plugin-fuer-wordpress.php" title="VG Wort Plugin - Heiner Otterstedt" target="_blank">
     298                                        <?php _e( 'VG-Wort Krimskram', 'wp-vgwort-locale' ); ?>
     299                                    </a>  -> "vgwpixel"
     300                                </li>
     301                            </ul>
     302                        </td>
     303                    </tr>
     304                    <tr valign="top">
     305                        <th scope="row"><h3><?php _e( 'Zeichen anzeigen', 'wp-vgwort-locale' ); ?>:</h3></th>
     306                        <td>
     307                            <?php
     308
     309                            $showCharsInOverview = true;
     310
     311                            // Zeichen Anzeigen:
     312                            if( isset( $vgWortOptions['showChars'] ) ) {
     313                                if( $vgWortOptions['showChars'] != '' ) {
     314                                    $showCharsInOverview = $vgWortOptions['showChars'];
     315                                }
     316                            }
     317
     318                            ?>
     319                            <span class="description"><?php _e( 'Soll in den ausgewählten Beiträgen die Zeichen Anzahl angezeigt werden?', 'wp-vgwort-locale' ); ?></span>
     320                            <br />
     321                            <?php if( $showCharsInOverview ) {  ?>
     322                                <input type="radio" name="showchars" value="0" /> <?php _e( 'Nein', 'wp-vgwort-locale' ); ?><br />
     323                                <input type="radio" name="showchars" checked="checked" value="1" /> <?php _e( 'Ja', 'wp-vgwort-locale' ); ?><br/>
     324                            <?php } else { ?>
     325                                <input type="radio" name="showchars" checked="checked" value="0" /> <?php _e( 'Nein', 'wp-vgwort-locale' ); ?><br />
     326                                <input type="radio" name="showchars" value="1" /> <?php _e( 'Ja', 'wp-vgwort-locale' ); ?><br/>
     327                            <?php } ?>
     328                        </td>
     329                    </tr>
     330                    <tr valign="top">
     331                        <th scope="row"> <h3><?php _e( 'Speichern', 'wp-vgwort-locale' ); ?>:</h3> </th>
     332                        <td>
     333                            <input type="hidden" name="action" value="save" />
     334                            <input type="submit" name="save" value="<?php _e( 'Einstellung speichern', 'wp-vgwort-locale' ); ?>" class="button-primary" / >
     335                        </td>
     336                    </tr>
     337                </table>
    341338            </form>
    342         <?php
    343         }
    344         ?>
    345 
    346     </div>
     339    <?php } ?>
     340</div>
  • wp-vgwort/trunk/wp-vgwort.php

    r733723 r734295  
    1313 * Plugin URI:  http://www.mywebcheck.de/vg-wort-plugin-wordpress/
    1414 * Description: Verwaltung der VG Wort Zählpixel
    15  * Version:     2.0.1
     15 * Version:     2.0.2
    1616 * Author:      Marcus Franke
    1717 * Author URI:  http://mywebcheck.de
Note: See TracChangeset for help on using the changeset viewer.