Plugin Directory

Changeset 2597187


Ignore:
Timestamp:
09/11/2021 07:50:52 AM (5 years ago)
Author:
avi.megladon
Message:

serve webp images using .htaccess

Location:
webp-converter
Files:
37 added
8 edited

Legend:

Unmodified
Added
Removed
  • webp-converter/trunk/css/webp-admin.css

    r2593052 r2597187  
    7272}
    7373.webp-top {
    74   margin-bottom: 20px;
     74  margin: 10px 0px 20px 0px;
     75  text-align: center;
    7576}
    7677.sub-images {
     
    133134  padding: 10px !important;
    134135}
     136.ui-tooltip {
     137  opacity: 1;
     138  filter: alpha(opacity=100);
     139}
     140.user-hta {
     141  border: 4px dashed #ccc;
     142  border-radius: 5px;
     143  padding: 10px;
     144  margin: 10px 0px;
     145  box-sizing: border-box;
     146}
  • webp-converter/trunk/includes/class-settings.php

    r2593052 r2597187  
    11<?php
    22namespace WEBP\Settings;
     3use WEBP\Htserve as Htserve;
    34
    45class APWEBP_Converter_Settings {
     
    3132            }
    3233
    33             $GLOBALS['msg'] = __('Plugin data successfully updated.', 'webp-converter') . '<br>';
     34            if (isset($_REQUEST['apwebp_image_quality'])) {
     35                update_option('apwebp_image_quality', sanitize_text_field($_REQUEST['apwebp_image_quality']));
     36            } else {
     37                delete_option('apwebp_image_quality');
     38            }
     39
     40            do_action('apwebp_save_settings');
     41
     42            $GLOBALS['msg'] = apply_filters('webp_msg_filter', __('Plugin data successfully updated.', 'webp-converter') . '<br>');
    3443        }
    3544    }
     
    8089
    8190    public function settings() {
     91        $hts = new Htserve\APWEBP_Htserve;
    8292        include APWEBP_DIRECTORY_PATH . '/view/admin/settings.php';
    8393    }
     
    128138            $post = [
    129139                'url' => $file_full_url,
     140                'quality' => get_option('apwebp_image_quality'),
    130141            ];
    131142
     
    140151            $post = [
    141152                'url' => $file_full_url,
     153                'quality' => get_option('apwebp_image_quality'),
    142154            ];
    143155            $response = $this->call_web_service($url, $post, $headers);
  • webp-converter/trunk/languages/webp-converter.pot

    r2593052 r2597187  
    44"Project-Id-Version: Webp Converter\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2021-08-30 06:05+0000\n"
     6"POT-Creation-Date: 2021-09-10 12:48+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1414"Content-Transfer-Encoding: 8bit\n"
    1515"X-Generator: Loco https://localise.biz/\n"
    16 "X-Loco-Version: 2.3.3; wp-5.5.5"
     16"X-Loco-Version: 2.3.3; wp-5.8.1"
    1717
    1818#. URI of the plugin
     
    2020msgstr ""
    2121
    22 #: includes/class-settings.php:182 includes/class-settings.php:185
    23 msgid "API calls left"
     22#: includes/class-htserve.php:199
     23msgid ".htaccess files are created successfully."
     24msgstr ""
     25
     26#: view/admin/settings.php:90
     27msgid ".htaccess on /uploads/ dir"
     28msgstr ""
     29
     30#: view/admin/settings.php:75
     31msgid ".htaccess on /wp-content/ dir"
     32msgstr ""
     33
     34#: includes/class-htserve.php:195
     35msgid ""
     36"/uploads/ dir not writable. Please check if the dir has correct permissions."
     37msgstr ""
     38
     39#: includes/class-htserve.php:191
     40msgid ""
     41"/wp-content/ dir not writable. Please check if the dir has correct "
     42"permissions."
    2443msgstr ""
    2544
     
    3251msgstr ""
    3352
    34 #: includes/class-settings.php:186
    35 msgid "day(s)"
    36 msgstr ""
    37 
    3853#: view/admin/settings.php:36
    3954msgid "Don't convert different image sizes"
     
    4257#: view/admin/settings.php:26
    4358msgid "Enable"
     59msgstr ""
     60
     61#: view/admin/settings.php:66
     62msgid ""
     63"Enable this so that images can be served in webp format using htaccess. This "
     64"is useful to serve images which are embedded in the page / post content with "
     65"full url."
    4466msgstr ""
    4567
     
    6890msgstr ""
    6991
    70 #: includes/class-settings.php:57
     92#: view/admin/settings.php:43
     93msgid "Image quality"
     94msgstr ""
     95
     96#: includes/class-settings.php:66
    7197msgid "Images per page"
    7298msgstr ""
    7399
    74 #: view/admin/converter-data.php:44
     100#: includes/class-htserve.php:203
     101msgid "Images will not be served as webp by .htaccess"
     102msgstr ""
     103
     104#: view/admin/converter-data.php:45
    75105msgid "items"
    76106msgstr ""
    77107
    78 #: view/admin/settings.php:51
     108#: view/admin/settings.php:112
    79109msgid "Plugin API Status"
    80110msgstr ""
    81111
    82 #: includes/class-settings.php:33
     112#: includes/class-settings.php:42
    83113msgid "Plugin data successfully updated."
    84114msgstr ""
    85115
    86 #: includes/class-settings.php:186
    87 msgid "Renew in"
    88 msgstr ""
    89 
    90 #: view/admin/settings.php:44
     116#: view/admin/settings.php:105
    91117msgid "Save"
    92118msgstr ""
    93119
    94 #: view/admin/converter-data.php:7
     120#: view/admin/settings.php:91
     121msgid ""
     122"Seems like the /uploads/ dir is not writable. Please create one .htaccess "
     123"file inside your uploads dir."
     124msgstr ""
     125
     126#: view/admin/settings.php:76
     127msgid ""
     128"Seems like the /wp-content/ dir is not writable. Please create one .htaccess "
     129"file inside your wp-content dir."
     130msgstr ""
     131
     132#: view/admin/converter-data.php:8
    95133msgid "Select All"
    96134msgstr ""
     
    102140msgstr ""
    103141
    104 #: view/admin/converter-data.php:9
     142#: view/admin/converter-data.php:10
    105143msgid "Start WEBP Image Converter"
    106144msgstr ""
     
    110148msgstr ""
    111149
    112 #: view/admin/converter-data.php:8
     150#: view/admin/converter-data.php:9
    113151msgid "Unselect All"
     152msgstr ""
     153
     154#: view/admin/settings.php:65
     155msgid "Use .htaccess to serve webp images"
    114156msgstr ""
    115157
  • webp-converter/trunk/readme.txt

    r2593052 r2597187  
    55Requires at least: 2.0.2
    66Tested up to: 5.8
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4444== Changelog ==
    4545
     46= 1.0.1 =
     47* Now embedded images can be served as webp using .htaccess
     48
    4649= 1.0.0 =
    4750* this is the first release.
  • webp-converter/trunk/view/admin/settings.php

    r2593052 r2597187  
    33<h1 class="wp-heading-inline" style="margin-bottom: 10px;"><?php _e('WEBP Images Settings', 'webp-converter');?></h1>
    44
    5 <?php if (isset($GLOBALS['msg'])) {echo '<div class="updated notice notice-success webp-msg is-dismissible">' . esc_html($GLOBALS['msg']) . '</div>';}?>
     5<?php if (isset($GLOBALS['msg'])) {echo '<div class="updated notice notice-success webp-msg is-dismissible">' . html_entity_decode(esc_html($GLOBALS['msg'])) . '</div>';}?>
    66
    77<form name="f" method="post" action="">
     
    3434          <tr>
    3535            <td valign="top" width="300"><strong><?php _e('Convert only full size images', 'webp-converter');?></strong></td>
    36             <td><label><input type="checkbox" name="apwebp_dont_conv_image_sizes" value="yes" <?php echo get_option('apwebp_dont_conv_image_sizes') == 'yes' ? 'checked="checked"' : ''; ?> /> <?php _e('Don\'t convert different image sizes', 'webp-converter');?></label></td>
     36            <td><label><input type="checkbox" name="apwebp_dont_conv_image_sizes" value="yes" <?php echo get_option('apwebp_dont_conv_image_sizes') == 'yes' ? 'checked="checked"' : ''; ?> /> <?php _e('Don\'t convert different thumbnail image sizes', 'webp-converter');?></label></td>
    3737           </tr>
    3838           <tr>
     
    4040            <td>&nbsp;</td>
    4141          </tr>
     42          <tr>
     43            <td valign="top" width="300"><strong><?php _e('Image quality', 'webp-converter');?></strong></td>
     44            <td>
     45              <label><input type="radio" name="apwebp_image_quality" value="50" <?php echo get_option('apwebp_image_quality') == '50' ? 'checked="checked"' : ''; ?> /> 50%</label>
     46
     47              <label><input type="radio" name="apwebp_image_quality" value="60" <?php echo get_option('apwebp_image_quality') == '60' ? 'checked="checked"' : ''; ?> /> 60%</label>
     48
     49              <label><input type="radio" name="apwebp_image_quality" value="70" <?php echo get_option('apwebp_image_quality') == '70' ? 'checked="checked"' : ''; ?> /> 70%</label>
     50
     51              <label><input type="radio" name="apwebp_image_quality" value="80" <?php echo get_option('apwebp_image_quality') == '80' ? 'checked="checked"' : ''; ?> /> 80%</label>
     52
     53              <label><input type="radio" name="apwebp_image_quality" value="90" <?php echo get_option('apwebp_image_quality') == '90' ? 'checked="checked"' : ''; ?> /> 90%</label>
     54
     55              <label><input type="radio" name="apwebp_image_quality" value="100" <?php echo get_option('apwebp_image_quality') == '100' ? 'checked="checked"' : ''; ?> /> 100%</label>
     56
     57          </td>
     58           </tr>
     59           <tr>
     60            <td>&nbsp;</td>
     61            <td>&nbsp;</td>
     62          </tr>
     63           <tr>
     64          <tr>
     65            <td valign="top" width="300"><strong><?php _e('Use .htaccess to serve webp images', 'webp-converter');?></strong></td>
     66            <td><label><input type="checkbox" name="apwebp_use_htaccess" value="yes" <?php echo get_option('apwebp_use_htaccess') == 'yes' ? 'checked="checked"' : ''; ?> /> <?php _e('Enable this so that images can be served in webp format using htaccess. This is useful to serve images which are embedded in the page / post content with full url.', 'webp-converter');?></label></td>
     67           </tr>
     68           <tr>
     69            <td>&nbsp;</td>
     70            <td>&nbsp;</td>
     71          </tr>
     72
     73          <?php if (get_option('apwebp_use_htaccess') == 'yes' and $hts->get_wpc_ht_data_to_user() !== false) {?>
     74            <tr>
     75            <td valign="top"><strong><?php _e('.htaccess on /wp-content/ dir', 'webp-converter');?></strong></td>
     76            <td><font color="red"><?php _e('Seems like the /wp-content/ dir is not writable. Please create one .htaccess file inside your wp-content dir.', 'webp-converter');?></font></td>
     77          </tr>
     78          <tr>
     79              <td>&nbsp;</td>
     80              <td><div class="user-hta"><?php echo $hts->get_wpc_ht_data_to_user(); ?></div></td>
     81            </tr>
     82            <tr>
     83              <td>&nbsp;</td>
     84              <td>&nbsp;</td>
     85            </tr>
     86          <?php }?>
     87
     88          <?php if (get_option('apwebp_use_htaccess') == 'yes' and $hts->get_wpu_ht_data_to_user() !== false) {?>
     89            <tr>
     90              <td valign="top"><strong><?php _e('.htaccess on /uploads/ dir', 'webp-converter');?></strong></td>
     91              <td><font color="red"><?php _e('Seems like the /uploads/ dir is not writable. Please create one .htaccess file inside your uploads dir.', 'webp-converter');?></font></td>
     92            </tr>
     93            <tr>
     94              <td>&nbsp;</td>
     95              <td><div class="user-hta"><?php echo $hts->get_wpu_ht_data_to_user(); ?></div></td>
     96            </tr>
     97            <tr>
     98              <td>&nbsp;</td>
     99              <td>&nbsp;</td>
     100            </tr>
     101          <?php }?>
     102
    42103          <tr>
    43104            <td>&nbsp;</td>
  • webp-converter/trunk/webp-converter.php

    r2593052 r2597187  
    44Plugin URI: #
    55Description: Speed up your website by serving images in WebP format. This plugin will replace files in standard JPEG, PNG and GIF formats with WebP format.
    6 Version: 1.0.0
     6Version: 1.0.1
    77Text Domain: webp-converter
    88Domain Path: /languages
     
    1919
    2020namespace WEBP\Init;
    21 
     21use WEBP\Htserve as Htserve;
    2222use WEBP\Init as Init;
    2323use WEBP\Scripts as Scripts;
     
    3434}
    3535
     36include_once APWEBP_DIRECTORY_PATH . '/includes/class-activate.php';
     37
    3638function plug_install_apwebp_converter() {
    3739    include_once ABSPATH . 'wp-admin/includes/plugin.php';
     
    4446    include_once APWEBP_DIRECTORY_PATH . '/includes/class-settings.php';
    4547    include_once APWEBP_DIRECTORY_PATH . '/includes/class-scripts.php';
     48    include_once APWEBP_DIRECTORY_PATH . '/includes/class-htserve.php';
    4649    include_once APWEBP_DIRECTORY_PATH . '/functions.php';
    4750
    4851    new Settings\APWEBP_Converter_Settings;
     52    new Htserve\APWEBP_Htserve;
    4953    new Scripts\APWEBP_Converter_Scripts;
    5054}
     
    5862new Init\APWEBP_Converter_Pre_Checking;
    5963
     64register_activation_hook(__FILE__, array('WEBP\Activate\APWEBP_Activate', 'webp_install'));
     65register_deactivation_hook(__FILE__, array('WEBP\Activate\APWEBP_Activate', 'webp_uninstall'));
     66
    6067add_filter('wp_get_attachment_image_src', 'apwebp_ap_convert_url_for_images', 10, 4);
    6168add_filter('wp_get_attachment_url', 'apwebp_ap_convert_url_for_attachments');
Note: See TracChangeset for help on using the changeset viewer.