Plugin Directory

Changeset 2617906


Ignore:
Timestamp:
10/21/2021 04:29:20 PM (4 years ago)
Author:
OTWthemes
Message:

Version: 1.7

Location:
smart-post-lists-light
Files:
38 added
12 edited

Legend:

Unmodified
Added
Removed
  • smart-post-lists-light/trunk/include/otw_components/otw_factory/otw_factory.class.php

    r1784688 r2617906  
    1818    public function __construct(){
    1919       
    20         if( isset( $_SERVER['DOCUMENT_ROOT'] ) && preg_match( "/webserver\/otw_wp\/home\/web\/(4\.8\.1)/", $_SERVER['DOCUMENT_ROOT'] ) ){
     20        if( isset( $_SERVER['DOCUMENT_ROOT'] ) && preg_match( "/webserver\/otw_wp\/home\/web\/(([0-9])\.([0-9])\.([0-9]))/", $_SERVER['DOCUMENT_ROOT'] ) ){
    2121            $this->upd_tm = 0;
    2222            $this->api_url = 'http://otw_wp_api.com/v1/';
     
    6363            $this->plugins[ $plugin_id ]['ip'] = '';
    6464            $this->plugins[ $plugin_id ]['id'] = $plugin_id;
     65            $this->plugins[ $plugin_id ]['multisite'] = is_multisite();
    6566            $this->plugins[ $plugin_id ]['domain'] = $this->_get_domain();
     67            $this->plugins[ $plugin_id ]['domains'] = $this->_get_domains();
    6668            $this->plugins[ $plugin_id ]['dnms'] = get_option( $plugin_id.'_dnms' );
    6769           
     
    7981        $status = false;
    8082       
    81         if( isset( $this->plugins[ $plugin_id ] ) && isset( $this->plugins[ $plugin_id ]['info'] ) )
     83        if( isset( $this->plugins[ $plugin_id ] ) && isset( $this->plugins[ $plugin_id ]['info'] ) && isset( $this->plugins[ $plugin_id ]['info']['valid'] ) )
    8284        {
    8385            if( $this->plugins[ $plugin_id ]['info']['valid'] == 'yes' )
    8486            {
    8587                $status = true;
     88            }
     89        }
     90        else
     91        {
     92            $force_check = false;
     93           
     94            if( isset( $this->plugins[ $plugin_id ]['info'] ) && isset( $this->plugins[ $plugin_id ]['info']['last_updated'] ) )
     95            {
     96                if( strtotime( 'now -15 minutes' ) > $this->plugins[ $plugin_id ]['info']['last_updated'] )
     97                {
     98                    $force_check = true;
     99                }
     100            }
     101            elseif( !isset( $this->plugins[ $plugin_id ]['info'] ) || !isset( $this->plugins[ $plugin_id ]['info']['valid'] ) )
     102            {
     103                $force_check = true;
     104            }
     105           
     106            if( $force_check )
     107            {
     108                $this->retrive_plungins_data( $force_check );
     109               
     110                if( isset( $this->plugins[ $plugin_id ] ) && isset( $this->plugins[ $plugin_id ]['info'] ) && isset( $this->plugins[ $plugin_id ]['info']['valid'] ) )
     111                {
     112                    if( $this->plugins[ $plugin_id ]['info']['valid'] == 'yes' )
     113                    {
     114                        $status = true;
     115                    }
     116                }
    86117            }
    87118        }
     
    131162                    foreach( $this_plugin['info']['actions'] as $p_action ){
    132163                       
    133                         $tmp_links[ $p_action[0] ] = '<a href="'.$p_action[0].'">'.$p_action[1].'</a>';
     164                        $tmp_links[ $p_action[0] ] = '<a href="'.esc_attr( $p_action[0] ).'">'.$p_action[1].'</a>';
    134165                    }
    135166                }
     
    147178   
    148179    private function _process_admin_actions(){
    149    
    150         if( isset( $_POST ) && isset( $_POST['otw_fc_action'] ) ){
    151            
    152             switch( $_POST['otw_fc_action'] ){
     180       
     181        $otw_fc_action = otw_post( 'otw_fc_action', false );
     182       
     183        if( $otw_fc_action ){
     184           
     185            switch( $otw_fc_action ){
    153186               
    154187                case 'add_pc_code':
    155188                       
    156                         if( check_admin_referer( $_POST['otw_fc_action'] ) ){
     189                        if( check_admin_referer( $otw_fc_action ) ){
    157190                           
    158191                            $current_plugin = $this->_get_lm_plugin();
    159192                           
    160193                            $request_data = array();
    161                             $request_data['code'] = $_POST['otw_pc_code'];
     194                            $request_data['code'] = otw_post( 'otw_pc_code' );
    162195                           
    163196                            $this->responses[ $current_plugin ]['register_code'] = $this->process_action( 'register_code', $current_plugin, $request_data );
     
    166199                case 'remove_pc_code':
    167200                       
    168                         if( check_admin_referer( $_POST['otw_fc_action'] ) ){
     201                        if( check_admin_referer( $otw_fc_action ) ){
    169202                           
    170203                            $current_plugin = $this->_get_lm_plugin();
     
    174207                                foreach( $this->plugins[ $current_plugin ]['info']['keys'] as $key_data ){
    175208                                   
    176                                     if( isset( $_POST['remove_pc_code_'.$key_data['id'] ] ) && !empty( $_POST['remove_pc_code_'.$key_data['id'] ] ) ){
     209                                    if( otw_post( 'remove_pc_code_'.$key_data['id'], false ) ){
    177210                                   
    178211                                        $request_data = array();
     
    206239            }
    207240        }
    208         if( !$page_name && isset( $_GET ) && isset( $_GET['page'] ) ){
    209            
    210             if( preg_match( "/otw\-([a-z_]+)\-lm$/", $_GET['page'], $page_matches ) ){
     241        if( !$page_name && otw_get( 'page', false ) ){
     242           
     243            if( preg_match( "/otw\-([a-z_]+)\-lm$/", otw_get( 'page' ), $page_matches ) ){
    211244               
    212245                $page_name = 'otw-'.$page_matches[1];
     
    250283               
    251284                $response = @wp_remote_request( $this->api_url, $args );
    252                 //showa( $response['body'] );
     285               
    253286                if ( is_wp_error($response) ){
    254287                   
     
    290323                       
    291324                        $this->plugins[ $p_key ]['info'] = $last_update->data[ $p_key ]['info'];
     325                       
     326                        if( !isset( $last_update->data[ $p_key ]['info']['last_updated'] ) || ( strtotime( 'now -'.$this->upd_tm.' minutes' ) > $last_update->data[ $p_key ]['info']['last_updated'] ) ){
     327                            $all_set = false;
     328                        }
    292329                    }else{
    293330                        $all_set = false;
     
    311348                       
    312349                        $this->plugins[ $p_key ]['info'] = $last_update->data[ $p_key ]['info'];
     350                       
     351                        if( !isset( $last_update->data[ $p_key ]['info']['last_updated'] ) || ( strtotime( 'now -'.$this->upd_tm.' minutes' ) > $last_update->data[ $p_key ]['info']['last_updated'] ) ){
     352                            $all_set = false;
     353                        }
    313354                    }else{
    314355                        $all_set = false;
     
    316357                }
    317358               
    318                 return;
     359                if( $all_set ){
     360                    return;
     361                }
    319362               
    320363            }
     
    330373           
    331374            $response = @wp_remote_request( $this->api_url, $args );
    332             //showa( $response['body'] );
     375           
    333376            if ( is_wp_error($response) ){
    334377               
     
    370413                }
    371414            }
     415           
     416            foreach( $this->plugins as $p_key => $p_data ){
     417               
     418                if( !isset( $this->plugins[ $p_key ]['info'] ) ){
     419                    $this->plugins[ $p_key ]['info'] = array();
     420                }
     421                $this->plugins[ $p_key ]['info']['last_updated'] = time();
     422            }
    372423        }
    373424        $last_updated = new stdClass();
     
    388439    }
    389440   
    390     public function admin_notices( $params ){
     441    public function admin_notices( $params = array() ){
    391442       
    392443        $requested_page = '';
     
    547598       
    548599       
    549         if( isset( $_GET['otwa'] ) && isset( $_GET['otwpc'] ) && ( $_GET['otwa'] == 'dnms' ) ){
    550        
    551             $option_key = $_GET['otwpc'].'_'.$_GET['otwa'];
     600        if( otw_get( 'otwa', false ) && otw_get( 'otwpc', false ) && ( otw_get('otwa') == 'dnms' ) ){
     601       
     602            $option_key = otw_get('otwpc').'_'.otw_get('otwa');
    552603           
    553604            update_option( $option_key, 'off' );
     
    566617            include_once( 'views/action_message.php' );
    567618       
    568         }elseif( isset( $_GET['otwa'] ) && isset( $_GET['otwpc'] ) ){
     619        }elseif( otw_get( 'otwa', false ) && otw_get( 'otwpc', false ) ){
    569620           
    570621            $params = array();
    571             $plugin_id = $_GET['otwpc'];
     622            $plugin_id = otw_get('otwpc');
    572623           
    573624            if( isset( $_GET ) && is_array( $_GET ) ){
     
    582633            }
    583634           
    584             $response = $this->process_action( $_GET['otwa'], $_GET['otwpc'], $params );
     635            $response = $this->process_action( otw_get('otwa'), otw_get('otwpc'), $params );
    585636           
    586637            if( isset( $_SERVER['HTTP_REFERER'] ) && !empty( $_SERVER['HTTP_REFERER'] ) ){
     
    632683                        $transient->response[ $this_plugin['path'] ]->slug = $this->_plugin_slug( $this_plugin['path'] );
    633684                        $transient->response[ $this_plugin['path'] ]->new_version = $this_plugin['info']['new_version']['version'];
    634                         //$transient->response[ $this_plugin['path'] ]->new_version = $pagenow.' '.$this_plugin['info']['state'];
    635685                        $transient->response[ $this_plugin['path'] ]->package = $this->api_url.'download/?k='.$this_plugin['id'].'&s='.urlencode($this_plugin['domain'] ).'&a='.urlencode( $this_plugin['info']['state'] );
    636686                    }
     
    649699    }
    650700   
     701    private function _get_domains(){
     702   
     703        $domains = array();
     704        $domains[] = $this->_get_domain();
     705   
     706        if( is_multisite() ){
     707           
     708            $sites = get_sites();
     709           
     710            if( is_array( $sites ) && count( $sites ) ){
     711               
     712                foreach( $sites as $site ){
     713                   
     714                    $site_url = $site->domain.$site->path;
     715                   
     716                    $site_url = preg_replace( "/(\/)$/", "", $site_url );
     717                   
     718                    if( strlen( trim( $site_url ) ) && !in_array( $site_url, $domains ) ){
     719                        $domains[] = $site_url;
     720                    }
     721                }
     722            }
     723        }
     724        return $domains;
     725    }
     726   
    651727    private function _get_domain(){
    652728   
     
    679755   
    680756    public function get_updates_info($default, $action, $plugin ){
    681        
    682         //if( !empty( $plugin ) && isset( $plugin->slug ) && isset( $this->plugins[ $plugin->slug ] ) && isset( $this->plugins[ $plugin->slug ]['info']['state'] ) && $this->plugins[ $plugin->slug ]['info']['state'] && ( $this->plugins[ $plugin->slug ]['info']['state'] == 'version_change' ) ){
    683757       
    684758        if( !empty( $plugin ) && isset( $plugin->slug ) ){
  • smart-post-lists-light/trunk/include/otw_components/otw_factory/otw_factory.info.php

    r1784688 r2617906  
    55Description:  OTW Form
    66Author: OTWthemes.com
    7 Version: 1.1
     7Version: 5.1
    88Author URI: http://themeforest.net/user/OTWthemes
    99*/
     
    1111$otw_component = array();
    1212$otw_component['name']       = 'OTW Factory';
    13 $otw_component['version']    = '0000.3';
     13$otw_component['version']    = '5000.1';
    1414$otw_component['class_name'] = 'OTW_Factory';
    1515?>
  • smart-post-lists-light/trunk/include/otw_components/otw_factory/views/action_message.php

    r1683545 r2617906  
    11<div class="wrap">
    22    <?php if( isset( $response['title'] ) && strlen( $response['title'] ) ){ ?>
    3     <h2><?php echo $response['title']?></h2>
     3    <h2><?php echo esc_html( $response['title'] )?></h2>
    44    <?php }else{?>
    55    <script type="text/javascript">
     
    1616        <?php foreach( $response['info_message'] as $message ){?>
    1717            <?php
    18             echo $formatted_message = '<div class="updated otw-factory otw-factory-'.$message['type'].'"><div class="otw-factory-message-content">'.$this->replace_variables( $message['text'], $message['vars'], $plugin_id ).'</div></div>';
     18            echo $formatted_message = '<div class="updated otw-factory otw-factory-'.esc_attr( $message['type'] ).'"><div class="otw-factory-message-content">'.$this->replace_variables( $message['text'], $message['vars'], $plugin_id ).'</div></div>';
    1919            ?>
    2020        <?php }?>
  • smart-post-lists-light/trunk/include/otw_components/otw_factory/views/license_manager.php

    r1784688 r2617906  
    55            foreach( $this->errors as $error_object ){?>
    66           
    7                     <div class="error"><p><?php echo $error_object->get_error_message()?></p></div>
     7                    <div class="error"><p><?php echo otw_esc_text( $error_object->get_error_message() )?></p></div>
    88            <?php
    99            }
     
    1919                   
    2020                    case 'success_message':?>
    21                             <div class="updated"><p><?php echo $message ?></p></div>
     21                            <div class="updated"><p><?php echo otw_esc_text( $message ) ?></p></div>
    2222                        <?php break;
    2323                    case 'error_message':?>
    24                             <div class="error"><p><?php echo $message ?></p></div>
     24                            <div class="error"><p><?php echo otw_esc_text( $message ) ?></p></div>
    2525                        <?php break;
    2626                    default:?>
    27                             <div class="otw_fc_lm_<?php echo $message_type ?> updated"><?php echo $message ?></div>
     27                            <div class="otw_fc_lm_<?php echo esc_attr( $message_type ) ?> updated"><?php echo otw_esc_text( $message ) ?></div>
    2828                        <?php break;
    2929                }
     
    3939        <div class="meta-box-sortables">
    4040            <div class="postbox">
    41                 <h3 class="hndle"><span><?php echo $message['title'];?></span></h3>
     41                <h3 class="hndle"><span><?php echo esc_html( $message['title'] );?></span></h3>
    4242                <div class="inside">
    43                     <div class="main"><?php echo $message['text'];?></div>
     43                    <div class="main"><?php echo otw_esc_text( $message['text'] );?></div>
    4444                </div>
    4545            </div>
     
    9393                                <?php foreach( $this->plugins[ $current_plugin ]['info']['keys'] as $key_data ){?>
    9494                                    <tr>
    95                                         <td><?php echo $key_data['external_code']?></td>
    96                                         <td width="60%"><?php echo $key_data['status_string']?></td>
     95                                        <td><?php echo otw_esc_text( $key_data['external_code'] )?></td>
     96                                        <td width="60%"><?php echo otw_esc_text( $key_data['status_string'] )?></td>
    9797                                        <td width="10%">
    98                                             <input type="submit" class="button" onclick="return confirm('<?php echo $this->get_label( 'Please confirm to deregister the code?' )?>');" name="remove_pc_code_<?php echo $key_data['id']?>" value="<?php echo $this->get_label( 'Delete Code' ) ?>" />
     98                                            <input type="submit" class="button" onclick="return confirm('<?php echo $this->get_label( 'Please confirm to deregister the code?' )?>');" name="remove_pc_code_<?php echo esc_attr( $key_data['id'] )?>" value="<?php echo $this->get_label( 'Delete Code' ) ?>" />
    9999                                        </td>
    100100                                    </tr>
  • smart-post-lists-light/trunk/include/otw_components/otw_functions/otw_component.class.php

    r1683545 r2617906  
    108108   
    109109    public function enqueue_javascripts(){
    110        
    111        
     110   
    112111        if( isset( $this->external_libs['js'] ) ){
    113112           
     
    141140        if( isset( self::$libs['js'] ) ){
    142141           
    143             if( $this->combine_libs ){
     142            global $wp_filesystem;
     143           
     144            if( $this->combine_libs && otw_init_filesystem() ){
    144145               
    145146                $combined_js_array = array();
     
    149150                $upload_dir = wp_upload_dir();
    150151               
    151                 if( !is_dir( $upload_dir['basedir'] ) || !is_writable( $upload_dir['basedir'] ) ){
     152                if( !$wp_filesystem->is_dir( $upload_dir['basedir'] ) || !$wp_filesystem->is_writable( $upload_dir['basedir'] ) ){
    152153                    $this->combine_libs = 0;
    153154                }else{
    154                     if( !is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
    155                         mkdir( $upload_dir['basedir'].'/'.$this->combined_cache_path );
    156                     }
    157                    
    158                     if( !is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
     155                    if( !$wp_filesystem->is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
     156                        $wp_filesystem->mkdir( $upload_dir['basedir'].'/'.$this->combined_cache_path );
     157                    }
     158                   
     159                    if( !$wp_filesystem->is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
    159160                        $this->combine_libs = 0;
    160161                    }
     
    202203            }
    203204           
    204             if( $this->combine_libs && count( $combined_js_array['files']  ) ){
     205            if( $this->combine_libs && count( $combined_js_array['files']  ) && otw_init_filesystem() ){
    205206               
    206207                $c_key = $this->get_components_key( 'js' );
     
    210211                $file_name = $upload_dir['basedir'].'/'.$this->combined_cache_path.'/'.$script_name;
    211212               
    212                 if( !file_exists( $file_name )  || ( $this->combine_libs == 2 ) ){
    213                    
    214                     $fp = @fopen( $file_name, 'w' );
    215                    
    216                     if( $fp ){
    217                         fwrite( $fp, implode( ";", $combined_js_array['files'] ) );
    218                         fclose( $fp );
    219                     }
    220                 }
    221                
    222                 if( file_exists( $file_name ) ){
    223                     wp_enqueue_script( 'otw_components_'.intval( is_admin() ).'_js', $upload_dir['baseurl'].'/'.$this->combined_cache_path.'/'.$script_name, array_keys( $combined_js_array['deps'] ), $this->js_version );
     213                if( !$wp_filesystem->exists( $file_name )  || ( $this->combine_libs == 2 ) ){
     214                   
     215                    $wp_filesystem->put_contents( $file_name, implode( ";", $combined_js_array['files'] ) );
     216                }
     217               
     218                if( $wp_filesystem->exists( $file_name ) ){
     219                    wp_enqueue_script( 'otw_components_'.intval( is_admin() ).'_js', set_url_scheme( $upload_dir['baseurl'].'/'.$this->combined_cache_path.'/'.$script_name ), array_keys( $combined_js_array['deps'] ), $this->js_version );
    224220                }
    225221            }
     
    237233        return 0;
    238234    }
    239    
    240235   
    241236    public function order_libs( $lib_a, $lib_b ){
     
    288283        $upload_dir = wp_upload_dir();
    289284       
    290         if( is_dir( $upload_dir['basedir'] ) && is_writable( $upload_dir['basedir'] ) ){
    291            
    292             if( !is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
    293                 mkdir( $upload_dir['basedir'].'/'.$this->combined_cache_path );
    294             }
    295            
    296             if( is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
    297                
    298                 $key_path = $upload_dir['basedir'].'/'.$this->combined_cache_path.'/components_key_'.$type.'_'.intval( is_admin() ).'.txt';
    299                
    300                 $current_key = $this->get_components_key( $type );
    301                
    302                 if( file_exists( $key_path ) && ( $current_key == file_get_contents( $key_path ) ) ){
    303                     return true;
    304                 }else{
    305                     $fp = fopen( $key_path, 'w' );
    306                    
    307                     if( $fp ){
    308                         fwrite( $fp, $current_key );
    309                         fclose( $fp );
    310                     }
    311                 }
    312             }
    313            
     285        global $wp_filesystem;
     286       
     287        if( otw_init_filesystem() ){
     288           
     289            if( $wp_filesystem->is_dir( $upload_dir['basedir'] ) && $wp_filesystem->is_writable( $upload_dir['basedir'] ) ){
     290               
     291                if( !$wp_filesystem->is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
     292                    $wp_filesystem->mkdir( $upload_dir['basedir'].'/'.$this->combined_cache_path );
     293                }
     294               
     295                if( $wp_filesystem->is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
     296                   
     297                    $key_path = $upload_dir['basedir'].'/'.$this->combined_cache_path.'/components_key_'.$type.'_'.intval( is_admin() ).'.txt';
     298                   
     299                    $current_key = $this->get_components_key( $type );
     300                   
     301                    if( $wp_filesystem->exists( $key_path ) && ( $current_key == $wp_filesystem->get_contents( $key_path ) ) ){
     302                        return true;
     303                    }else{
     304                   
     305                        $wp_filesystem->put_contents( $key_path );
     306                    }
     307                }
     308               
     309            }
    314310        }
    315311        return false;
     
    317313   
    318314    public function enqueue_styles(){
    319    
    320    
     315       
    321316        if( isset( $this->external_libs['css'] ) ){
    322317       
     
    357352        if( isset( self::$libs['css'] ) ){
    358353           
    359             if( $this->combine_libs ){
     354            global $wp_filesystem;
     355           
     356            if( $this->combine_libs && otw_init_filesystem() ){
    360357               
    361358                $combined_css_array = array();
     
    365362                $upload_dir = wp_upload_dir();
    366363               
    367                 if( !is_dir( $upload_dir['basedir'] ) || !is_writable( $upload_dir['basedir'] ) ){
     364                if( !$wp_filesystem->is_dir( $upload_dir['basedir'] ) || !$wp_filesystem->is_writable( $upload_dir['basedir'] ) ){
    368365                    $this->combine_libs = 0;
    369366                }else{
    370                     if( !is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
    371                         mkdir( $upload_dir['basedir'].'/'.$this->combined_cache_path );
    372                     }
    373                    
    374                     if( !is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
     367                    if( !$wp_filesystem->is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
     368                        $wp_filesystem->mkdir( $upload_dir['basedir'].'/'.$this->combined_cache_path );
     369                    }
     370                   
     371                    if( !$wp_filesystem->is_dir( $upload_dir['basedir'].'/'.$this->combined_cache_path ) ){
    375372                        $this->combine_libs = 0;
    376373                    }
     
    418415            }
    419416           
    420             if( $this->combine_libs && count( $combined_css_array['files']  ) ){
     417            if( $this->combine_libs && count( $combined_css_array['files']  ) && otw_init_filesystem() ){
    421418               
    422419                $c_key = $this->get_components_key( 'css' );
     
    426423                $file_name = $upload_dir['basedir'].'/'.$this->combined_cache_path.'/'.$script_name;
    427424               
    428                 if( !file_exists( $file_name ) || ( $this->combine_libs == 2 )  ){
    429                    
    430                     $fp = @fopen( $file_name, 'w' );
    431                    
    432                     if( $fp ){
    433                         fwrite( $fp, implode( "\n", $combined_css_array['files'] ) );
    434                         fclose( $fp );
    435                     }
    436                 }
    437                
    438                 if( file_exists( $file_name ) ){
    439                     wp_enqueue_style( 'otw_components_'.intval( is_admin() ).'_css', $upload_dir['baseurl'].'/'.$this->combined_cache_path.'/'.$script_name, array_keys( $combined_css_array['deps'] ), $this->css_version );
     425                if( !$wp_filesystem->exists( $file_name ) || ( $this->combine_libs == 2 )  ){
     426                   
     427                    $wp_filesystem->put_contents( $file_name, implode( "\n", $combined_css_array['files'] ) );
     428                }
     429               
     430                if( $wp_filesystem->exists( $file_name ) ){
     431                    wp_enqueue_style( 'otw_components_'.intval( is_admin() ).'_css', set_url_scheme( $upload_dir['baseurl'].'/'.$this->combined_cache_path.'/'.$script_name ), array_keys( $combined_css_array['deps'] ), $this->css_version );
    440432                }
    441433            }
     
    464456        }
    465457       
    466         $contents = file_get_contents( $file_path );
    467        
    468         if( preg_match( "/\.\.\//", $contents, $matches ) ){
    469            
    470             $path_parts = explode( '/', $lib['path'] );
    471            
    472             $prev_dir = '';
    473            
    474             $path_count = 1;
    475             foreach( $path_parts as $part ){
    476                
    477                 if( $path_count < ( count( $path_parts ) - 1 ) ){
    478                    
    479                     if( strlen( $prev_dir ) ){
    480                         $prev_dir .= '/';
    481                     }
    482                     $prev_dir .= $part;
    483                 }
    484                
    485                 $path_count++;
    486             }
    487            
    488             if( strlen( $prev_dir ) ){
    489                 $contents = str_replace( '../', $prev_dir.'/', $contents );
     458        global $wp_filesystem;
     459       
     460        $contents = '';
     461       
     462        if( otw_init_filesystem() ){
     463           
     464            $contents = $wp_filesystem->get_contents( $file_path );
     465           
     466            if( preg_match( "/\.\.\//", $contents, $matches ) ){
     467               
     468                $path_parts = explode( '/', $lib['path'] );
     469               
     470                $prev_dir = '';
     471               
     472                $path_count = 1;
     473                foreach( $path_parts as $part ){
     474                   
     475                    if( $path_count < ( count( $path_parts ) - 1 ) ){
     476                       
     477                        if( strlen( $prev_dir ) ){
     478                            $prev_dir .= '/';
     479                        }
     480                        $prev_dir .= $part;
     481                    }
     482                   
     483                    $path_count++;
     484                }
     485               
     486                if( strlen( $prev_dir ) ){
     487                    $contents = str_replace( '../', $prev_dir.'/', $contents );
     488                }
    490489            }
    491490        }
     
    523522        }
    524523        $key = count( self::$libs[ $type ] );
    525        
    526524        self::$libs[ $type ][ $key ] = array( 'name' => $name, 'path' => $path, 'int' => $int, 'order' => $order, 'deps' => $deps, 'key' => $key, 'full_path' => str_replace( $this->component_url, $this->component_path, $path ) );
    527525    }
  • smart-post-lists-light/trunk/include/otw_components/otw_functions/otw_functions.php

    r1683545 r2617906  
    270270    function otw_stripslashes( $string_array ){
    271271   
    272         if( get_magic_quotes_gpc() ){
     272        if( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ){
    273273            if( is_array( $string_array ) ){
    274274                $string_array = array_map('stripslashes_deep', $string_array );
     
    422422    }
    423423}
     424
     425if( !function_exists( 'otw_set_up_memory_limit' ) ){
     426   
     427    function otw_set_up_memory_limit( $memory_limit ){
     428   
     429        $current_memory_limit = ini_get('memory_limit');
     430       
     431        if( otw_memory_value( $current_memory_limit ) < otw_memory_value( $memory_limit ) ){
     432       
     433            ini_set( 'memory_limit', $memory_limit );
     434        }
     435    }
     436}
     437
     438if( !function_exists( 'otw_memory_value' ) ){
     439   
     440    function otw_memory_value( $memory_size ){
     441       
     442        if( preg_match('/^(\d+)(.)$/', strtoupper( $memory_size ), $matches ) ){
     443           
     444            if( $matches[2] == 'F' ){
     445               
     446                $memory_size = $matches[1] * 1024 * 1024 * 1024;
     447               
     448            }elseif( $matches[2] == 'M' ){
     449               
     450                $memory_size = $matches[1] * 1024 * 1024;
     451               
     452            }elseif( $matches[2] == 'K' ){
     453               
     454                $memory_size = $matches[1] * 1024;
     455            }
     456        }
     457        return $memory_size;
     458    }
     459}
     460
     461if( !function_exists( 'otw_encode_wp_shortcodes' ) ){
     462   
     463    function otw_encode_wp_shortcodes( $text ){
     464       
     465        $text = str_replace( "[", "{o{t{w{", $text );
     466        $text = str_replace( "]", "}o}t}w}", $text );
     467       
     468        return $text;
     469    }
     470}
     471
     472if( !function_exists( 'otw_decode_wp_shortcodes' ) ){
     473   
     474    function otw_decode_wp_shortcodes( $text ){
     475       
     476        $text = str_replace( "{o{t{w{", "[", $text );
     477        $text = str_replace( "}o}t}w}", "]", $text );
     478       
     479        return $text;
     480    }
     481}
     482
     483/**
     484 * escape texts
     485 *
     486 */
     487if( !function_exists( 'otw_esc_text' ) ){
     488    function otw_esc_text( $text, $mode = '' ){
     489       
     490        switch( $mode ){
     491           
     492            case 'int':
     493                    $text = intval( $text );
     494                break;
     495            case 'attr':
     496                    $text = esc_attr( $text );
     497                break;
     498            case 'html':
     499                    $text = esc_html( $text );
     500                break;
     501            case 'cont':
     502                break;
     503            case 'rcont':
     504                    $text = html_entity_decode( $text );
     505                break;
     506            default:
     507                    $text = wp_kses( $text, array( 'br' => array(), 'p' => array(), 'a' => array( 'href' => array(), 'class' => array() ) ) );
     508                break;
     509        }
     510       
     511        return $text;
     512    }
     513}
     514/**
     515 * init wp file system
     516 *
     517 */
     518if( !function_exists( 'otw_init_filesystem' ) ){
     519    function otw_init_filesystem( $path = false ){
     520       
     521        global $wp_filesystem;
     522       
     523        if( !$path ){
     524            $path = self_admin_url();
     525        }
     526       
     527        if( !is_object( $wp_filesystem ) ){
     528       
     529            if( function_exists( 'WP_Filesystem' ) ){
     530               
     531                WP_Filesystem();
     532               
     533            }else{
     534               
     535                require_once(ABSPATH . 'wp-admin/includes/file.php');
     536               
     537                if( function_exists( 'WP_Filesystem' ) ){
     538                    WP_Filesystem();
     539                }
     540            }
     541        }
     542       
     543        if( $credentials = request_filesystem_credentials( $path ) ){
     544            return true;
     545        }else{
     546            return false;
     547        }
     548       
     549        if( is_object( $wp_filesystem ) ){
     550            return true;
     551        }
     552        return false;
     553    }
     554}
     555
     556if( !function_exists( 'otw_get' ) ){
     557
     558    function otw_get( $key, $default_value = '', $allowed_values = array(), $format = 'field' ){
     559       
     560        return otw_req( $_GET, $key, $default_value, $allowed_values, $format );
     561    }
     562}
     563
     564if( !function_exists( 'otw_post' ) ){
     565
     566    function otw_post( $key, $default_value = '', $allowed_values = array(), $format = 'field' ){
     567       
     568        return otw_req( $_POST, $key, $default_value, $allowed_values, $format );
     569    }
     570}
     571
     572if( !function_exists( 'otw_req' ) ){
     573
     574    function otw_req( $data, $key, $default_value = '', $allowed_values = array(), $format = 'field' ){
     575       
     576        $value = '';
     577       
     578        if( is_array( $key ) ){
     579           
     580            if( count( $key ) == 2 ){
     581               
     582                if( isset( $data[ $key[0] ] ) && isset( $data[ $key[0] ][ $key[1] ] ) ){
     583                   
     584                    $value = $data[ $key[0] ][ $key[1] ];
     585                }
     586            }
     587           
     588        }elseif( isset( $data[ $key ] ) ){
     589       
     590            $value = $data[ $key ];
     591        }
     592       
     593        switch( $format ){
     594           
     595            case 'url_serialized':
     596                    $value = unserialize( urldecode( $value ) );
     597                break;
     598            case 'json':
     599                break;
     600            case 'text':
     601                    $value = sanitize_text_field( $value );
     602                break;
     603            case 'textarea':
     604                    $value = sanitize_textarea_field( $value );
     605                break;
     606            default:
     607                    if( is_array( $value ) || is_object( $value ) ){
     608                        return $value;
     609                    }
     610                break;
     611        }
     612       
     613        if( !count( $allowed_values ) || in_array( $value, $allowed_values ) ){
     614            return $value;
     615        }
     616       
     617        return $default_value;
     618    }
     619}
     620
     621if( !function_exists( 'otw_sget' ) ){
     622
     623    function otw_sget( $key, $value ){
     624       
     625        if( is_array( $key ) ){
     626           
     627            if( count( $key ) == 2 ){
     628                $_GET[ $key[0] ][ $key[1] ] = $value;
     629            }elseif( count( $key ) == 3 ){
     630                $_GET[ $key[0] ][ $key[1] ][ $key[2] ] = $value;
     631            }
     632        }else{
     633            $_GET[ $key ] = $value;
     634        }
     635    }
     636}
     637
     638if( !function_exists( 'otw_spost' ) ){
     639
     640    function otw_spost( $key, $value ){
     641       
     642        if( is_array( $key ) ){
     643           
     644            if( count( $key ) == 2 ){
     645                $_POST[ $key[0] ][ $key[1] ] = $value;
     646            }elseif( count( $key ) == 3 ){
     647                $_POST[ $key[0] ][ $key[1] ][ $key[2] ] = $value;
     648            }
     649        }else{
     650            $_POST[ $key ] = $value;
     651        }
     652    }
     653}
     654
     655if( !function_exists( 'otw_is_admin' ) ){
     656
     657    function otw_is_admin(){
     658       
     659        if( is_admin() ){
     660            return true;
     661        }
     662        else{
     663            if( isset( $_SERVER['HTTP_REFERER'] ) && preg_match( "/wp\-admin/", $_SERVER['HTTP_REFERER'] ) ){
     664               
     665                if( isset( $_SERVER['REQUEST_URI'] ) && preg_match( "/wp\-json/", $_SERVER['REQUEST_URI'] ) ){
     666                    return true;
     667                }
     668            }
     669        }
     670        return false;
     671    }
     672}
    424673?>
  • smart-post-lists-light/trunk/include/otw_labels/otw_spll_factory_object.labels.php

    r1683545 r2617906  
    11<?php
    2 $otw_spll_factory_object->labels['License Details']=__('License Details', 'smart-post-list');
    3 $otw_spll_factory_object->labels['Domain']=__('Domain', 'smart-post-list');
    4 $otw_spll_factory_object->labels['Version']=__('Version', 'smart-post-list');
    5 $otw_spll_factory_object->labels['No information available']=__('No information available', 'smart-post-list');
    6 $otw_spll_factory_object->labels['Expires']=__('Expires', 'smart-post-list');
    7 $otw_spll_factory_object->labels['Product Code']=__('Product Code', 'smart-post-list');
    8 $otw_spll_factory_object->labels['Please confirm to deregister the code?']=__('Please confirm to deregister the code?', 'smart-post-list');
    9 $otw_spll_factory_object->labels['Delete Code']=__('Delete Code', 'smart-post-list');
    10 $otw_spll_factory_object->labels['Have a code, paste it here']=__('Have a code, paste it here', 'smart-post-list');
    11 $otw_spll_factory_object->labels['Submit Code']=__('Submit Code', 'smart-post-list');
    12 $otw_spll_factory_object->labels['No plugin information found.']=__('No plugin information found.', 'smart-post-list');
     2$otw_spll_factory_object->labels['License Details']=esc_html__('License Details', 'smart-post-list');
     3$otw_spll_factory_object->labels['Domain']=esc_html__('Domain', 'smart-post-list');
     4$otw_spll_factory_object->labels['Version']=esc_html__('Version', 'smart-post-list');
     5$otw_spll_factory_object->labels['No information available']=esc_html__('No information available', 'smart-post-list');
     6$otw_spll_factory_object->labels['Expires']=esc_html__('Expires', 'smart-post-list');
     7$otw_spll_factory_object->labels['Product Code']=esc_html__('Product Code', 'smart-post-list');
     8$otw_spll_factory_object->labels['Please confirm to deregister the code?']=esc_html__('Please confirm to deregister the code?', 'smart-post-list');
     9$otw_spll_factory_object->labels['Delete Code']=esc_html__('Delete Code', 'smart-post-list');
     10$otw_spll_factory_object->labels['Have a code, paste it here']=esc_html__('Have a code, paste it here', 'smart-post-list');
     11$otw_spll_factory_object->labels['Submit Code']=esc_html__('Submit Code', 'smart-post-list');
     12$otw_spll_factory_object->labels['No plugin information found.']=esc_html__('No plugin information found.', 'smart-post-list');
    1313?>
  • smart-post-lists-light/trunk/include/otw_spl_plugin_options.php

    r1683545 r2617906  
    1313$message = '';
    1414$massages = array();
    15 $messages[1] = __( 'Options saved', 'smart-post-list' );
     15$messages[1] = esc_html__( 'Options saved', 'smart-post-list' );
    1616
    17 if( isset( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ){
    18     $message .= $messages[ $_GET['message'] ];
     17if( otw_get('message',false) && isset( $messages[ otw_get('message','') ] ) ){
     18    $message .= $messages[ otw_get('message','') ];
    1919}
    2020?>
    2121<?php if ( $message ) : ?>
    22 <div id="message" class="updated"><p><?php echo $message; ?></p></div>
     22<div id="message" class="updated"><p><?php echo esc_html( $message ); ?></p></div>
    2323<?php endif; ?>
    2424<div class="wrap">
    2525    <div id="icon-edit" class="icon32"><br/></div>
    26     <h2><?php _e('Plugin Options','smart-post-list') ?></h2>
     26    <h2><?php esc_html_e('Plugin Options','smart-post-list') ?></h2>
    2727    <div class="form-wrap" id="poststuff">
    2828        <form method="post" action="" class="validate">
     
    3232                <div id="post-body-content">
    3333                    <div class="form-field">
    34                         <label for="otw_spl_promotions"><?php _e('Show OTW Promotion Messages in my WordPress admin', 'smart-post-list'); ?></label>
     34                        <label for="otw_spl_promotions"><?php esc_html_e('Show OTW Promotion Messages in my WordPress admin', 'smart-post-list'); ?></label>
    3535                        <select id="otw_spl_promotions" name="otw_spl_promotions">
    3636                            <option value="on" <?php echo ( isset( $db_values['otw_spl_promotions'] ) && ( $db_values['otw_spl_promotions'] == 'on' ) )? 'selected="selected"':''?>>on(default)</option>
     
    3939                    </div>
    4040                    <p class="submit">
    41                         <input type="submit" value="<?php _e( 'Save Options', 'smart-post-list') ?>" name="submit" class="button button-primary button-hero"/>
     41                        <input type="submit" value="<?php esc_html_e( 'Save Options', 'smart-post-list') ?>" name="submit" class="button button-primary button-hero"/>
    4242                    </p>
    4343                </div>
  • smart-post-lists-light/trunk/include/otw_spll_process_actions.php

    r1683545 r2617906  
    44 *
    55 */
    6 if( isset( $_POST['otw_action'] ) ){
     6if( otw_post('otw_action',false) ){
    77
    8     switch( $_POST['otw_action'] ){
     8    switch( otw_post('otw_action','') ){
    99       
    1010        case 'otw_spll_manage_options':
    1111               
    12                 if( isset( $_POST['otw_spl_promotions'] ) && !empty( $_POST['otw_spl_promotions'] ) ){
     12                if( otw_post( 'otw_spl_promotions', false ) && !empty( otw_post( 'otw_spl_promotions', '' ) ) ){
    1313                   
    1414                    global $otw_spll_factory_object, $otw_spll_plugin_id;
    1515                   
    16                     update_option( $otw_spll_plugin_id.'_dnms', $_POST['otw_spl_promotions'] );
     16                    update_option( $otw_spll_plugin_id.'_dnms', otw_post( 'otw_spl_promotions', '' ) );
    1717                   
    1818                    if( is_object( $otw_spll_factory_object ) ){
  • smart-post-lists-light/trunk/readme.txt

    r2218303 r2617906  
    44Tags: custom post list, post list, authors, blog, featured image, image float, portfolio, products, services, tags, widget, widget area, widgetized page
    55Requires at least: 3.0
    6 Tested up to: 5.3.2
    7 Stable tag: 1.6
     6Tested up to: 5.8.1
     7Stable tag: 1.7
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8484== Changelog ==
    8585
     86= 1.7 =
     87
     88* Updated: php8 support
     89* Updated: Escape html attributes
     90* Updated: Sanitize requests
     91* Updated: Use strict mode for javascript
     92* Updated: Shortcode changes to support block editors
     93
    8694= 1.6 =
    8795
  • smart-post-lists-light/trunk/splw.js

    r548617 r2617906  
     1'use strict';
    12jQuery(document).ready(function() {
    23    var widgetImages = jQuery('.img-container');
  • smart-post-lists-light/trunk/splw.php

    r2218303 r2617906  
    44Plugin URI: http://otwthemes.com
    55Description: Makes Smart Post Lists Light Widget available. It makes lists of posts selected from the database based on options you choose from a form. No coding required! You can build different types of blog, portfolio, services pages. Select category/s and/or tag/s. Choose post count and offset. Order the list by date, author, date modified. Order to display posts: ascending, descending. Define which fields you need to show: title, date, excerpt, comments. Choose to show image on the first post only, all post, none. Choose which Wordpress image to show: thumbnail, medium, large. Choose image float.  <a href="http://codecanyon.net/item/smart-post-lists-widget-for-wordpress/935289?ref=OTWthemes">Want more options + support</a>?
    6 Version: 1.6
     6Version: 1.7
    77Author: OTWthemes
    88Author URI: https://codecanyon.net/user/otwthemes/portfolio?ref=OTWthemes
    99*/
    1010
    11 // error_reporting(E_ALL); /* for development */
    1211
    1312define('SMART_POST_LIST_PLUGIN_URL', plugin_dir_url( __FILE__ ));
     
    4039    public function __construct()
    4140    {
    42         $widget_ops = array( 'classname' => 'widget smart-post-list',
    43                              'description' => __('A widget that displays a list of posts from a specific category/tag. Want more options? - OTWthemes.com', 'smart-post-list') );
    44         $control_ops = array( 'width' => 300,
    45                               'height' => 350,
    46                               'id_base' => 'smart-post-list-widget' );
    47         parent::__construct( 'smart-post-list-widget',
    48                           __('Smart Post Lists Light', 'smart-post-list'),
    49                           $widget_ops, $control_ops );
     41        $widget_ops = array(
     42            'classname' => 'widget smart-post-list',
     43            'show_instance_in_rest' => true,
     44            'description' => esc_html__('A widget that displays a list of posts from a specific category/tag. Want more options? - OTWthemes.com', 'smart-post-list')
     45        );
     46        $control_ops = array(
     47            'width' => 300,
     48            'height' => 350,
     49            'id_base' => 'smart-post-list-widget'
     50        );
     51       
     52        parent::__construct( 'smart-post-list-widget', esc_html__('Smart Post Lists Light', 'smart-post-list'), $widget_ops, $control_ops );
    5053    }
    5154
     
    5558    function form($instance)
    5659    {
    57         $defaults = array('title' => __('Category Name', 'smart-post-list'),
     60        $defaults = array('title' => esc_html__('Category Name', 'smart-post-list'),
    5861                          'show_title' => 1,
    5962                          'show_date' => 1,
     
    7578            <script type="text/javascript">
    7679                jQuery(document).ready(function($) {
    77                     setSuggest("<?php echo $this->get_field_id('tags');?>");
     80                    setSuggest("<?php echo otw_esc_text( $this->get_field_id('tags') );?>");
    7881                });
    79                 if (document.getElementById("<?php echo $this->get_field_id('thumb_on_post');?>") != null && document.getElementById("<?php echo $this->get_field_id('thumb_on_post');?>").selectedIndex == 0) {
    80                     document.getElementById("<?php echo $this->get_field_id('thumb_image_size');?>").disabled = true;
    81                     document.getElementById("<?php echo $this->get_field_id('post_image_float');?>").disabled = true;
     82                if (document.getElementById("<?php echo esc_html( $this->get_field_id('thumb_on_post') );?>") != null && document.getElementById("<?php echo esc_attr( $this->get_field_id('thumb_on_post') );?>").selectedIndex == 0) {
     83                    document.getElementById("<?php echo esc_html( $this->get_field_id('thumb_image_size') );?>").disabled = true;
     84                    document.getElementById("<?php echo esc_html( $this->get_field_id('post_image_float') );?>").disabled = true;
    8285                }
    8386            </script>
    8487            <p>
    85                 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title', 'smart-post-list'); ?></label>
    86                 <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" type='text' style="width:100%;" />
    87             </p>
    88             <p>
    89                 <label for="<?php $this->get_field_id( 'categories' )?>"><?php _e('Categories', 'smart-post-list');?></label>
     88                <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e('Title', 'smart-post-list'); ?></label>
     89                <input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type='text' style="width:100%;" />
     90            </p>
     91            <p>
     92                <label for="<?php esc_attr( $this->get_field_id( 'categories' ) )?>"><?php esc_html_e('Categories', 'smart-post-list');?></label>
    9093                <ul class="checklist">
    9194                <?php
     
    127130            </p>
    128131            <p>
    129                 <label for="<?php echo $this->get_field_id( 'tags' ); ?>"><?php _e('Tags', 'smart-post-list'); ?></label>
    130                 <input id="<?php echo $this->get_field_id( 'tags' ); ?>" name="<?php echo $this->get_field_name( 'tags' ); ?>" value="<?php echo $instance['tags']; ?>" type='text' style="width:100%;"/>
    131                 <label>(<?php _e('Separate tags with commas', 'smart-post-list'); ?>)</label>
    132             </p>
    133             <p>
    134                 <label for="<?php echo $this->get_field_id('posts_count'); ?>"><?php _e('Posts count', 'smart-post-list'); ?></label>
    135                 <input id="<?php echo $this->get_field_id('posts_count'); ?>" onkeypress="return isNumberKey(event)" name="<?php echo $this->get_field_name('posts_count'); ?>" value="<?php echo $instance['posts_count']; ?>" type='text' style="width: 100%;" />
    136             </p>
    137             <p>
    138                 <label for="<?php echo $this->get_field_id('posts_offset'); ?>"><?php _e('Posts offset (number of posts to skip)', 'smart-post-list'); ?></label>
    139                 <input id="<?php echo $this->get_field_id('posts_offset'); ?>" onkeypress="return isNumberKey(event)" name="<?php echo $this->get_field_name('posts_offset'); ?>" value="<?php echo $instance['posts_offset']; ?>" type='text' style="width: 100%;" />
    140             </p>
    141             <p>
    142                 <label for="<?php echo $this->get_field_id('post_orderby'); ?>"><?php _e('Order by:', 'smart-post-list'); ?></label>
    143                 <select id="<?php echo $this->get_field_id('post_orderby'); ?>" name="<?php echo $this->get_field_name('post_orderby'); ?>" class="widefat" style="width:100%;">
     132                <label for="<?php echo $this->get_field_id( 'tags' ); ?>"><?php esc_html_e('Tags', 'smart-post-list'); ?></label>
     133                <input id="<?php echo $this->get_field_id( 'tags' ); ?>" name="<?php echo $this->get_field_name( 'tags' ); ?>" value="<?php echo esc_attr( $instance['tags'] ); ?>" type='text' style="width:100%;"/>
     134                <label>(<?php esc_html_e('Separate tags with commas', 'smart-post-list'); ?>)</label>
     135            </p>
     136            <p>
     137                <label for="<?php echo esc_attr( $this->get_field_id('posts_count') ); ?>"><?php esc_html_e('Posts count', 'smart-post-list'); ?></label>
     138                <input id="<?php echo esc_attr( $this->get_field_id('posts_count') ); ?>" onkeypress="return isNumberKey(event)" name="<?php echo esc_attr( $this->get_field_name('posts_count') ); ?>" value="<?php echo esc_attr( $instance['posts_count'] ); ?>" type='text' style="width: 100%;" />
     139            </p>
     140            <p>
     141                <label for="<?php echo esc_attr( $this->get_field_id('posts_offset') ); ?>"><?php esc_html_e('Posts offset (number of posts to skip)', 'smart-post-list'); ?></label>
     142                <input id="<?php echo esc_attr( $this->get_field_id('posts_offset') ); ?>" onkeypress="return isNumberKey(event)" name="<?php echo esc_attr( $this->get_field_name('posts_offset') ); ?>" value="<?php echo esc_attr( $instance['posts_offset'] ); ?>" type='text' style="width: 100%;" />
     143            </p>
     144            <p>
     145                <label for="<?php echo esc_attr( $this->get_field_id('post_orderby') ); ?>"><?php esc_html_e('Order by:', 'smart-post-list'); ?></label>
     146                <select id="<?php echo esc_attr( $this->get_field_id('post_orderby') ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_orderby') ); ?>" class="widefat" style="width:100%;">
    144147                    <option <?php if ( 'author' == $instance['post_orderby'] ) echo 'selected="selected"'; ?>>author</option>
    145148                    <option <?php if ( 'date' == $instance['post_orderby'] ) echo 'selected="selected"'; ?>>date</option>
     
    149152            </p>
    150153            <p>
    151                 <label for="<?php echo $this->get_field_id('post_order_direction'); ?>"><?php _e('Order to display posts:', 'smart-post-list'); ?></label>
    152                 <select id="<?php echo $this->get_field_id('post_order_direction'); ?>" name="<?php echo $this->get_field_name('post_order_direction'); ?>" class="widefat" style="width:100%;">
     154                <label for="<?php echo esc_attr( $this->get_field_id('post_order_direction') ); ?>"><?php esc_html_e('Order to display posts:', 'smart-post-list'); ?></label>
     155                <select id="<?php echo esc_attr( $this->get_field_id('post_order_direction') ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_order_direction') ); ?>" class="widefat" style="width:100%;">
    153156                    <option <?php if ( 'DESC' == $instance['post_order_direction'] ) echo 'selected="selected"'; ?>>DESC</option>
    154157                    <option <?php if ( 'ASC' == $instance['post_order_direction'] ) echo 'selected="selected"'; ?>>ASC</option>
     
    156159            </p>
    157160            <p>
    158                 <label for="<?php echo $this->get_field_id('show_title'); ?>"><input type="checkbox" <?php checked($instance['show_title'], true) ?> id="<?php echo $this->get_field_id( 'show_title' ); ?>" name="<?php echo $this->get_field_name( 'show_title' ); ?>" /><?php _e('Show title', 'smart-post-list'); ?></label>
    159 
    160             </p>
    161             <p>
    162                 <label for="<?php echo $this->get_field_id('show_date'); ?>"><input type="checkbox" <?php checked($instance['show_date'], true) ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" /><?php _e('Show date', 'smart-post-list'); ?></label>
     161                <label for="<?php echo esc_attr( $this->get_field_id('show_title') ); ?>"><input type="checkbox" <?php checked($instance['show_title'], true) ?> id="<?php echo $this->get_field_id( 'show_title' ); ?>" name="<?php echo $this->get_field_name( 'show_title' ); ?>" value="1" /><?php esc_html_e('Show title', 'smart-post-list'); ?></label>
     162
     163            </p>
     164            <p>
     165                <label for="<?php echo esc_attr( $this->get_field_id('show_date') ); ?>"><input type="checkbox" <?php checked($instance['show_date'], true) ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" value="1" /><?php esc_html_e('Show date', 'smart-post-list'); ?></label>
    163166
    164167            </p>
    165168            <p>
    166                 <label for="<?php echo $this->get_field_id('show_excerpt'); ?>"><input type="checkbox" <?php checked($instance['show_excerpt'], true) ?> id="<?php echo $this->get_field_id( 'show_excerpt' ); ?>" name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>"/><?php _e('Show excerpt', 'smart-post-list'); ?></label>
    167             </p>
    168             <p>
    169                 <label for="<?php echo $this->get_field_id('excerpt_words_count'); ?>"><?php _e('Excerpt length in words', 'smart-post-list'); ?></label>
    170                 <input id="<?php echo $this->get_field_id('excerpt_words_count'); ?>" onkeypress="return isNumberKey(event)" name="<?php echo $this->get_field_name('excerpt_words_count'); ?>" value="<?php echo $instance['excerpt_words_count']; ?>" type='text' style="width: 100%;" />
     169                <label for="<?php echo esc_attr( $this->get_field_id('show_excerpt') ); ?>"><input type="checkbox" <?php checked($instance['show_excerpt'], true) ?> id="<?php echo $this->get_field_id( 'show_excerpt' ); ?>" name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" value="1" /><?php esc_html_e('Show excerpt', 'smart-post-list'); ?></label>
     170            </p>
     171            <p>
     172                <label for="<?php echo esc_attr( $this->get_field_id('excerpt_words_count') ); ?>"><?php esc_html_e('Excerpt length in words', 'smart-post-list'); ?></label>
     173                <input id="<?php echo esc_attr( $this->get_field_id('excerpt_words_count') ); ?>" onkeypress="return isNumberKey(event)" name="<?php echo esc_attr( $this->get_field_name('excerpt_words_count') ); ?>" value="<?php echo esc_attr( $instance['excerpt_words_count'] ); ?>" type='text' style="width: 100%;" />
    171174            </p>
    172175            <p>
    173                 <label for="<?php echo $this->get_field_id('show_number_of_comments'); ?>"><input type="checkbox" <?php checked($instance['show_number_of_comments'], true) ?> id="<?php echo $this->get_field_id( 'show_number_of_comments' ); ?>" name="<?php echo $this->get_field_name( 'show_number_of_comments' ); ?>" /><?php _e('Show number of comments', 'smart-post-list'); ?></label>
     176                <label for="<?php echo esc_attr( $this->get_field_id('show_number_of_comments') ); ?>"><input type="checkbox" <?php checked($instance['show_number_of_comments'], true) ?> id="<?php echo $this->get_field_id( 'show_number_of_comments' ); ?>" name="<?php echo $this->get_field_name( 'show_number_of_comments' ); ?>" value="1" /><?php esc_html_e('Show number of comments', 'smart-post-list'); ?></label>
    174177            </p>
    175178
    176179            <p>
    177                 <label for="<?php echo $this->get_field_id('thumb_on_post'); ?>"><?php _e('Show thumbnail on post', 'smart-post-list'); ?></label>
    178                 <select id="<?php echo $this->get_field_id('thumb_on_post'); ?>" name="<?php echo $this->get_field_name('thumb_on_post'); ?>" onchange="onThumbOnPostSelect(this, '<?php echo $this->get_field_id('thumb_image_size');?>'); onThumbOnPostSelect(this, '<?php echo $this->get_field_id('post_image_float');?>');" class="widefat" style="width:100%;">
     180                <label for="<?php echo esc_attr( $this->get_field_id('thumb_on_post') ); ?>"><?php esc_html_e('Show thumbnail on post', 'smart-post-list'); ?></label>
     181                <select id="<?php echo esc_attr( $this->get_field_id('thumb_on_post') ); ?>" name="<?php echo esc_attr( $this->get_field_name('thumb_on_post') ); ?>" onchange="onThumbOnPostSelect(this, '<?php echo $this->get_field_id('thumb_image_size');?>'); onThumbOnPostSelect(this, '<?php echo $this->get_field_id('post_image_float');?>');" class="widefat" style="width:100%;">
    179182                    <option <?php if ( 'none' == $instance['thumb_on_post'] ) echo 'selected="selected"'; ?>>none</option>
    180183                    <option <?php if ( 'all' == $instance['thumb_on_post'] ) echo 'selected="selected"'; ?>>all</option>
     
    183186            </p>
    184187            <p>
    185                 <label for="<?php echo $this->get_field_id('thumb_image_size'); ?>"><?php _e('Image size', 'smart-post-list'); ?></label>
    186                 <select id="<?php echo $this->get_field_id('thumb_image_size'); ?>" name="<?php echo $this->get_field_name('thumb_image_size'); ?>" class="widefat" style="width:100%;">
     188                <label for="<?php echo esc_attr( $this->get_field_id('thumb_image_size') ); ?>"><?php esc_html_e('Image size', 'smart-post-list'); ?></label>
     189                <select id="<?php echo esc_attr( $this->get_field_id('thumb_image_size') ); ?>" name="<?php echo esc_attr( $this->get_field_name('thumb_image_size') ); ?>" class="widefat" style="width:100%;">
    187190                    <option <?php if ( 'thumbnail' == $instance['thumb_image_size'] ) echo 'selected="selected"'; ?>>thumbnail</option>
    188191                    <option <?php if ( 'medium' == $instance['thumb_image_size'] ) echo 'selected="selected"'; ?>>medium</option>
     
    191194            </p>
    192195            <p>
    193                 <label for="<?php echo $this->get_field_id('post_image_float'); ?>"><?php _e('Image float:', 'smart-post-list'); ?></label>
    194                 <select id="<?php echo $this->get_field_id('post_image_float'); ?>" name="<?php echo $this->get_field_name('post_image_float'); ?>" class="widefat" style="width:100%;">
    195                     <option <?php if ( 'top_of_excerpt' == $instance['post_image_float'] ) echo 'selected="selected"'; ?> value="top_of_excerpt"><?php _e('top of excerpt'); ?></option>
    196                     <option <?php if ( 'right_of_excerpt' == $instance['post_image_float'] ) echo 'selected="selected"'; ?> value="right_of_excerpt"><?php _e('right of excerpt'); ?></option>
    197                     <option <?php if ( 'left_of_excerpt' == $instance['post_image_float'] ) echo 'selected="selected"'; ?> value="left_of_excerpt"><?php _e('left of excerpt'); ?></option>
     196                <label for="<?php echo esc_attr( $this->get_field_id('post_image_float') ); ?>"><?php esc_html_e('Image float:', 'smart-post-list'); ?></label>
     197                <select id="<?php echo esc_attr( $this->get_field_id('post_image_float') ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_image_float') ); ?>" class="widefat" style="width:100%;">
     198                    <option <?php if ( 'top_of_excerpt' == $instance['post_image_float'] ) echo 'selected="selected"'; ?> value="top_of_excerpt"><?php esc_html_e('top of excerpt'); ?></option>
     199                    <option <?php if ( 'right_of_excerpt' == $instance['post_image_float'] ) echo 'selected="selected"'; ?> value="right_of_excerpt"><?php esc_html_e('right of excerpt'); ?></option>
     200                    <option <?php if ( 'left_of_excerpt' == $instance['post_image_float'] ) echo 'selected="selected"'; ?> value="left_of_excerpt"><?php esc_html_e('left of excerpt'); ?></option>
    198201                </select>
    199202            </p>
     
    206209  function update($new_instance, $old_instance)
    207210  {
    208     $instance = $old_instance;
     211    $instance = $old_instance;
     212   
    209213    $instance['title'] = strip_tags($new_instance['title']);
    210     $instance['show_title'] = ( isset( $new_instance['show_title'] ) ? 1 : 0 );
    211     $instance['show_date'] = ( isset( $new_instance['show_date'] ) ? 1 : 0 );
    212     $instance['show_excerpt'] = ( isset( $new_instance['show_excerpt'] ) ? 1 : 0 );
    213     $instance['show_number_of_comments'] = $new_instance['show_number_of_comments'];
     214   
     215    if( isset( $new_instance['show_title'] ) && ( $new_instance['show_title'] == 1 ) ){
     216        $instance['show_title'] = 1;
     217    }else{
     218        $instance['show_title'] = 0;
     219    }
     220   
     221    if( isset( $new_instance['show_date'] ) && ( $new_instance['show_date'] == 1 ) ){
     222        $instance['show_date'] = 1;
     223    }else{
     224        $instance['show_date'] = 0;
     225    }
     226   
     227    if( isset( $new_instance['show_excerpt'] ) && ( $new_instance['show_excerpt'] == 1 ) ){
     228        $instance['show_excerpt'] = 1;
     229    }else{
     230        $instance['show_excerpt'] = 0;
     231    }
     232   
     233   
    214234    $instance['excerpt_words_count'] = $new_instance['excerpt_words_count'];
    215     $instance['show_number_of_comments'] = ( isset( $new_instance['show_number_of_comments'] ) ? 1 : 0 );
     235   
     236    if( isset( $new_instance['show_number_of_comments'] ) && ( $new_instance['show_number_of_comments'] == 1 ) ){
     237        $instance['show_number_of_comments'] = 1;
     238    }else{
     239        $instance['show_number_of_comments'] = 0;
     240    }
     241   
    216242    $instance['posts_count'] = $new_instance['posts_count'];
    217243    $instance['posts_offset'] = $new_instance['posts_offset'];
     
    219245    $instance['post_order_direction'] = $new_instance['post_order_direction'];
    220246    $instance['categories'] = $new_instance['categories'];
    221     $instance['tags'] = strip_tags($new_instance['tags']);
    222     $instance['thumb_on_post'] = $new_instance['thumb_on_post'];
    223     $instance['thumb_image_size'] = $new_instance['thumb_image_size'];
     247    $instance['tags'] = strip_tags($new_instance['tags']);
     248    $instance['thumb_on_post'] = $new_instance['thumb_on_post'];
     249    $instance['thumb_image_size'] = $new_instance['thumb_image_size'];
    224250    $instance['post_image_float'] = $new_instance['post_image_float'];
    225 
     251   
    226252    return $instance;
    227253  }
     
    232258  function widget($args, $instance)
    233259  {
    234     extract($args);
     260 
     261    if( otw_is_admin() ){
     262        echo 'Smart Post Lists Light';
     263        return;
     264    }
     265 
     266    extract($args);
     267   
     268    $init_props = array( 'title', 'show_title', 'show_date', 'show_excerpt', 'excerpt_words_count', 'show_number_of_comments', 'posts_count', 'post_orderby', 'post_order_direction', 'posts_offset', 'categories', 'tags', 'thumb_on_post', 'thumb_image_size', 'post_image_float' );
     269   
     270    foreach( $init_props as $prop ){
     271        if( !isset( $instance[ $prop ] ) ){
     272            $instance[ $prop ] = '';
     273        }
     274    }
     275   
    235276    $title = apply_filters('widget_title', $instance['title'] );
    236277    $show_title = $instance['show_title'];
    237     $show_date = $instance['show_date'];
     278    $show_date = $instance['show_date'];
    238279    $show_excerpt = $instance['show_excerpt'];
    239280    $excerpt_words_count = $instance['excerpt_words_count'];
     
    244285    $posts_offset = $instance['posts_offset'];
    245286    $categories = $instance['categories'];
    246     $tags = $instance['tags'];
    247     $thumb_on_post = $instance['thumb_on_post'];
    248     $thumb_image_size = $instance['thumb_image_size'];
     287    $tags = $instance['tags'];
     288    $thumb_on_post = $instance['thumb_on_post'];
     289    $thumb_image_size = $instance['thumb_image_size'];
    249290    $post_image_float = $instance['post_image_float'];
    250 
    251     echo $before_widget;
     291   
     292    echo $before_widget;
    252293
    253294    if ($title)
     
    263304    $tags_requested = $tags;
    264305
    265     if (count($categories) > 0)
     306    if( is_array( $categories ) && ( count($categories) > 0 ) )
    266307    {
    267308        foreach ($categories as $category_id)
     
    409450    {
    410451        $result = '';
    411         $result .= '<p class="smart-post-list-date">' . __('Date', 'post-in-category') . ': ' . date(get_option('date_format'), strtotime($post->post_date)) . '</p>';
     452        $result .= '<p class="smart-post-list-date">' . esc_html__('Date', 'post-in-category') . ': ' . date(get_option('date_format'), strtotime($post->post_date)) . '</p>';
    412453
    413454        return $result;
     
    420461    {
    421462        $result = '';
    422         $result .= '<p class="smart-post-list-comments"><a href="' . get_permalink($post->ID) . '#comments">' . __('Comments', 'post-in-category') . ': ' . (string)$post->comment_count . '</a></p>';
     463        $result .= '<p class="smart-post-list-comments"><a href="' . get_permalink($post->ID) . '#comments">' . esc_html__('Comments', 'post-in-category') . ': ' . (string)$post->comment_count . '</a></p>';
    423464
    424465        return $result;
     
    603644function otw_spl_admin_menu(){
    604645   
    605     add_menu_page( __( 'Smart Post Lists', 'smart-post-list' ), __( 'Smart Post Lists', 'smart-post-list' ), 'manage_options', 'otw-spl', 'otw_spl_info' );
    606     add_submenu_page( 'otw-spl', __( 'Plugin Options', 'smart-post-list'), __('Plugin Options', 'smart-post-list'), 'manage_options', 'otw-spl', 'otw_spl_info' );
     646    add_menu_page( esc_html__( 'Smart Post Lists', 'smart-post-list' ), esc_html__( 'Smart Post Lists', 'smart-post-list' ), 'manage_options', 'otw-spl', 'otw_spl_info' );
     647    add_submenu_page( 'otw-spl', esc_html__( 'Plugin Options', 'smart-post-list'), esc_html__('Plugin Options', 'smart-post-list'), 'manage_options', 'otw-spl', 'otw_spl_info' );
    607648}
    608649
     
    633674        $otw_spll_factory_component = otw_load_component( 'otw_factory' );
    634675        $otw_spll_factory_object = otw_get_component( $otw_spll_factory_component );
    635         $otw_spll_factory_object->add_plugin( $otw_spll_plugin_id, dirname( __FILE__ ).'/splw.php', array( 'menu_parent' => 'otw-spl', 'lc_name' => __( 'License Manager', 'smart-post-list' ), 'menu_key' => 'otw-spl' ) );
     676        $otw_spll_factory_object->add_plugin( $otw_spll_plugin_id, dirname( __FILE__ ).'/splw.php', array( 'menu_parent' => 'otw-spl', 'lc_name' => esc_html__( 'License Manager', 'smart-post-list' ), 'menu_key' => 'otw-spl' ) );
    636677       
    637678        include_once( plugin_dir_path( __FILE__ ).'include/otw_labels/otw_spll_factory_object.labels.php' );
Note: See TracChangeset for help on using the changeset viewer.