Plugin Directory

Changeset 2743511


Ignore:
Timestamp:
06/16/2022 12:46:38 PM (4 years ago)
Author:
seenthis
Message:

update to 1.1.1

Location:
greenweb
Files:
34 added
5 edited

Legend:

Unmodified
Added
Removed
  • greenweb/trunk/README.txt

    r2738505 r2743511  
    7979== Changelog ==
    8080
     81= 1.1.1 =
     82* Bugfix: If there is no prefix or wrong/failing prefix the plugin will not alter the src of image.
     83* Bugfix: Where admin settings can't be reached.
     84
    8185= 1.1.0 =
    8286* Name change from Greenweb to Apart
  • greenweb/trunk/admin/class-greenweb-admin.php

    r2738502 r2743511  
    7474     */
    7575    public function set_admin_menu() {
    76         add_menu_page( $this->plugin_name, greenweb_globals\pluginName, 'manage_options', $this->plugin_name.'/admin/partials/apart-admin-display.php');
     76        add_menu_page( $this->plugin_name, greenweb_globals\pluginName, 'manage_options', greenweb_globals\rootFolder.'/admin/partials/apart-admin-display.php');
    7777    }
    7878}
  • greenweb/trunk/admin/js/greenweb-admin.js

    r2732598 r2743511  
    3939
    4040  function greenweb_check_Prefix(func, val) {
    41     fetch(optiUrl + val + latestEnd).then((response) =>
    42       func(val, response.status)
    43     );
     41    fetch(optiUrl + val + latestEnd).then((response) => {
     42      func(val, response.status);
     43    });
    4444  }
    4545
    4646  $(document).ready(function () {
    4747    if (pref) greenweb_check_Prefix(checkStatusStart, pref);
    48 
    4948    $('#gwForm').submit(function (e) {
    5049      e.preventDefault();
    5150      const val = e.target[0].value.trim();
    5251
    53       if (!/^[A-Za-z0-9]*$/.test(val)) {
    54         checkStatus(400);
    55         return;
    56       }
     52      // if (!/^[A-Za-z0-9]*$/.test(val)) {
     53      //   checkStatus(400);
     54      //   return;
     55      // }
    5756      greenweb_check_Prefix(updateOption, val);
    5857    });
  • greenweb/trunk/apart.php

    r2738502 r2743511  
    1313 * Plugin URI:        seenthis.co
    1414 * Description:       APART reduces your site’s carbon footprint and improves user experience by reducing its image data transfer and improving image load times.
    15  * Version:           1.1.0
     15 * Version:           1.1.1
    1616 * Author:            Seenthis
    1717 * Author URI:        https://www.seenthis.co
     
    101101    <?php }
    102102
    103 add_action('wp_head', 'hook_javascript');
    104 
    105 /**
    106  * Set links for greenweb at plugins.
    107  * @return Url to plugin settings
    108  */
    109 function getSettingsUrl(){
    110     return admin_url() . 'admin.php?page='. greenweb_globals\baseName .'/admin/partials/apart-admin-display.php';
    111 }
    112 
    113 /**
    114  * Set links for greenweb at plugins.
    115  * @param $links
    116  * @return mixed
    117  */
    118 function addSettingsLink($links) {
    119     $links[] = '<a href="' . getSettingsUrl() . '">Settings</a>';
    120    
    121     return $links;
    122 }
    123 
    124 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'addSettingsLink');
    125 
    126 /**
    127  * When redirect to adminpage when activated
    128  * @param $plugin
    129  */
    130 function redirectOnActivate($plugin) {
    131     if( $plugin === plugin_basename(__FILE__) ) {
    132         exit( wp_redirect( getSettingsUrl() ) );
    133     }
    134 }
    135 
    136 add_action( 'activated_plugin', 'redirectOnActivate' );
    137 
    138 /**
    139  * Change src for greenweb.
    140  * @param $content
    141  * @return mixed
    142  */
    143 function greenweb($content) {
     103    add_action('wp_head', 'hook_javascript');
     104
     105    /**
     106     * Set links for greenweb at plugins.
     107     * @return Url to plugin settings
     108     */
     109    function getSettingsUrl(){
     110        return admin_url() . 'admin.php?page='. greenweb_globals\rootFolder .'/admin/partials/apart-admin-display.php';
     111    }
     112
     113    /**
     114     * Set links for greenweb at plugins.
     115     * @param $links
     116     * @return mixed
     117     */
     118    function addSettingsLink($links) {
     119        $links[] = '<a href="' . getSettingsUrl() . '">Settings</a>';
     120       
     121        return $links;
     122    }
     123
     124    add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'addSettingsLink');
     125
     126    /**
     127     * When redirect to adminpage when activated
     128     * @param $plugin
     129     */
     130    function redirectOnActivate($plugin) {
     131        if( $plugin === plugin_basename(__FILE__) ) {
     132            exit( wp_redirect( getSettingsUrl() ) );
     133        }
     134    }
     135
     136    add_action( 'activated_plugin', 'redirectOnActivate' );
     137
     138
     139    /**
     140     * Function to change greenweb option from ajax
     141     * @param
     142     */
     143    function update_greenweb_option_ajax(){
     144
     145        $val = sanitize_text_field($_POST["option"]);
     146
     147        if (!preg_match('/[^A-Za-z0-9]/', $val)){
     148            update_option(greenweb_globals\option, $val);
     149            return http_response_code(200);
     150        } else return http_response_code(403);
     151        die();
     152    }
     153
     154    add_action( 'wp_ajax_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' );
     155    add_action( 'wp_ajax_nopriv_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' );
     156
     157    global $greenweb_globals;
     158    global $latest;
     159
     160
     161    // Check if prefix is ok othervise dont load plugin functions
     162    if (!$greenweb_globals->prefix || $greenweb_globals->prefix === '403') {
     163        return;
     164    }
     165    $response = wp_remote_get($latest);
     166    $http_code = wp_remote_retrieve_response_code($response);
     167    if ($http_code !== 200) {
     168        return;
     169    }
     170
     171    /**
     172     * Change src for greenweb.
     173     * @param $content
     174     * @return mixed
     175     */
     176    function greenweb($content) {
    144177        $content  = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
    145178        if ($content) {
     
    221254    }
    222255
    223 
    224     // Function to change greenweb option from ajax
    225     function update_greenweb_option_ajax(){
    226 
    227             $val = sanitize_text_field($_POST["option"]);
    228 
    229         if (!preg_match('/[^A-Za-z0-9]/', $val)){
    230             update_option(greenweb_globals\option, $val);
    231             return http_response_code(200);
    232         } else return http_response_code(403);
    233         die();
    234     }
    235 
    236     add_action( 'wp_ajax_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' );
    237     add_action( 'wp_ajax_nopriv_' . 'greenweb_option_ajax', 'update_greenweb_option_ajax' );
    238 
    239256    //Cron 
    240257   
  • greenweb/trunk/greenweb_globals.php

    r2738502 r2743511  
    88const pluginName = 'Apart';
    99const baseName = 'apart';
    10 const version = '1.1.0';
     10const rootFolder = 'greenweb';
     11const version = '1.1.1';
    1112
    1213class greenweb_settings{
Note: See TracChangeset for help on using the changeset viewer.