Plugin Directory

Changeset 2302481


Ignore:
Timestamp:
05/11/2020 09:27:47 AM (6 years ago)
Author:
webmarcello
Message:

minify CSS and JS
source search type bug Fixed
admin model created

Location:
news-search-engine/trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • news-search-engine/trunk/assets/admin.js

    r2279997 r2302481  
    8282}
    8383
    84 
    8584var hideForm = function () {
    8685
  • news-search-engine/trunk/includes/NewsSearchEngineAdmin.php

    r2280064 r2302481  
    33
    44    class NewsSearchEngineAdmin {
     5
     6        private $model;
    57
    68        public function __construct(){
     
    1214                add_action( 'admin_notices', array( $this, 'adminError' ) );
    1315            }
     16
     17            $this->model = new NewsSearchEngineModel;
    1418        }
    1519
     
    6468            // check if the post is comming from setting page
    6569            if(sanitize_text_field( $_POST['submit'] ) == 'Save Settings'){
    66                 update_option( 'news-search-engine-api-key', sanitize_text_field( $_POST['news-search-engine-api-key'] ) );
    67                 update_option( 'news-search-engine-default-page-size', sanitize_text_field( $_POST['news-search-engine-default-page-size'] ) );
    68                 update_option( 'news-search-engine-http', sanitize_text_field( $_POST['news-search-engine-http'] ) );
     70                $this->model->setData($_POST);
    6971
    7072                // save api key
    7173                if($_POST['news-search-engine-api-key']){
    72                     update_option( 'news-search-engine-settings-message', 'Settings saved.');
     74                    $this->model->setMessage('Settings saved.');
    7375                    $this->adminRedirect();
    7476                    return true;
    7577                }
    7678
    77                 update_option( 'news-search-engine-settings-message', 'Please insert API key.');
     79                $this->model->setMessage('Please insert API key.');
    7880                $this->adminRedirect();
    7981                return false;
     
    102104        // import CSS and JS
    103105        public function adminStyle() {
    104             wp_enqueue_script('news-search-engine-admin', PLUGIN_NSE_URL . 'assets/admin.js' );
    105             wp_enqueue_style('news-search-engine-admin', PLUGIN_NSE_URL . 'assets/admin.css', array(), null, 'all' );
     106            wp_enqueue_script('news-search-engine-admin', PLUGIN_NSE_URL . 'assets/admin.min.js', array( 'jquery' ), '1.0.0', true );
     107            wp_enqueue_style('news-search-engine-admin', PLUGIN_NSE_URL . 'assets/admin.min.css', array(), null, 'all' );
    106108        }
    107109
  • news-search-engine/trunk/includes/NewsSearchEngineRespose.php

    r2279997 r2302481  
    88        private $APIData;
    99        private $totalRow;
     10        private $pagination;
    1011
    1112        // write the response and route the response to part of the class
     
    1314
    1415            if($response->status == 'ok'){
    15                 if($response->sources)
     16                if($response->sources){
    1617                    $this->prepareTable($response->sources);
    1718                    $this->totalRow = count($response->sources);
    18                 if($response->articles){
     19                    $this->pagination = false;
     20                }
     21                elseif($response->articles){
    1922                    $this->prepareTable($response->articles);
    2023                    $this->totalRow = $response->totalResults;
     24                    $this->pagination = true;
    2125                }
    2226                return true;
     
    8286        public function display_table(){
    8387            echo '<div class="wrap" id="table-result-wrap">';
    84            
    85             if($this->totalRow){
     88
     89            if($this->totalRow && $this->pagination){
    8690                echo '<h3>Total Resutls ' . $this->totalRow . ' - Total Pages ' . (intval($this->totalRow / sanitize_text_field( $_POST['news-search-engine-page-size'] )) + 1 ). '</h3>';
    8791                $this->display_pagination();
     92            }
     93            elseif($this->totalRow){
     94                echo '<h3>Total Resutls ' . $this->totalRow . ' - Total Pages 1 </h3>';           
    8895            }
    8996
     
    9198            $this->display();
    9299
    93             if($this->totalRow){
     100            if($this->totalRow  && $this->pagination){
    94101                $this->display_pagination();
    95102            }
  • news-search-engine/trunk/news-search-engine.php

    r2280050 r2302481  
    44 * Plugin URI:        https://github.com/webmarcello8080/news-search-engine
    55 * Description:       News Search Engine is a Wordpress plugin that create a new section on the Wordpress Dashboard and it gives the possibility to search news through Google news API.
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Requires at least: 4.5.13
    88 * Requires PHP:      7.0
  • news-search-engine/trunk/readme.txt

    r2280066 r2302481  
    8080== Changelog ==
    8181
     82= 1.0.1 =
     83* JS and CSS minified
     84* bug fixed in pagination for source serach type
     85
    8286= 1.0.0 =
    8387* Creating settings from
  • news-search-engine/trunk/views/admin-form.php

    r2279997 r2302481  
    179179            // render output
    180180            if($response->renderResponse($result)){
    181                 $response->prepare_items();
    182181                $response->display_table();
    183182            }
Note: See TracChangeset for help on using the changeset viewer.