Changeset 1868268
- Timestamp:
- 05/03/2018 04:54:57 PM (8 years ago)
- Location:
- octify/trunk
- Files:
-
- 4 added
- 5 edited
-
Controller (added)
-
Controller/Compress.php (added)
-
Controller/Payment.php (added)
-
Controller/Settings.php (added)
-
Libs/OctifyApi.php (modified) (1 diff)
-
Octify.php (modified) (9 diffs)
-
View/dashboard2.php (modified) (3 diffs)
-
assets/script.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
octify/trunk/Libs/OctifyApi.php
r1860529 r1868268 341 341 // return; 342 342 // } 343 344 $currentStatus = get_post_meta( $attachmentId, self::META_STATUS, true );345 if ( $currentStatus == 'compressed' ) {346 //wont compress which already compressed347 return;348 }349 350 343 $file = get_attached_file( $attachmentId ); 351 344 if ( ! function_exists( 'download_url' ) ) { -
octify/trunk/Octify.php
r1860529 r1868268 4 4 * Plugin URI: https://octify.io 5 5 * Description: Octify Image Compression for WordPress. 6 * Version: 1. 1.46 * Version: 1.2 7 7 * Author: Octify 8 8 * Author URI: https://octify.io … … 43 43 add_action( 'admin_enqueue_scripts', array( &$this, 'adminScripts' ) ); 44 44 add_action( 'admin_menu', array( &$this, 'adminMenu' ) ); 45 add_action( 'wp_loaded', array( &$this, 'saveSettings' ) ); 46 add_action( 'wp_loaded', array( &$this, 'activate' ) ); 47 add_action( 'wp_loaded', array( &$this, 'extend' ) ); 48 add_action( 'wp_loaded', array( &$this, 'getFreeKey' ) ); 45 add_action( 'wp_loaded', array( '\Octify\Controller\Settings', 'saveSettings' ) ); 46 add_action( 'wp_loaded', array( '\Octify\Controller\Payment', 'activate' ) ); 47 add_action( 'wp_loaded', array( '\Octify\Controller\Payment', 'getFreeKey' ) ); 49 48 //inject octify to media page 50 49 add_filter( 'manage_media_columns', array( &$this, 'columns' ) ); … … 60 59 add_action( 'wp_ajax_octify_revert', array( &$this, 'revert' ) ); 61 60 // 62 add_action( 'wp_ajax_start_bulk_octify', array( &$this, 'startBulkOctify' ) );63 add_action( 'wp_ajax_get_bulk_octify_status', array( &$this, 'getOctifyStatus' ) );61 add_action( 'wp_ajax_start_bulk_octify', array( '\Octify\Controller\Compress', 'bulkOctify' ) ); 62 add_action( 'wp_ajax_get_bulk_octify_status', array( '\Octify\Controller\Compress', 'getOctifyStatus' ) ); 64 63 // 65 64 add_action( 'wp_shutdown', function () { … … 72 71 add_action( 'wp_loaded', array( &$this, 'revertAll' ) ); 73 72 } 73 74 // 75 } 76 77 public function maybeResetStatus() { 78 //find all the pending images 79 $pending = \Octify\Libs\OctifyApi::findImages( 'pending' ); 80 if ( count( $pending ) == 0 ) { 81 return; 82 } 83 84 //check time 85 $data = array(); 86 foreach ( $pending as $image ) { 87 $data[] = wp_get_attachment_image_url( $image->ID, 'full' ); 88 } 89 90 $request = wp_remote_post( \Octify\Libs\OctifyApi::API_ENDPOINT . 'v1/compress/check_images_status', array( 91 'body' => array( 92 'site_url' => network_site_url(), 93 'images' => $data 94 ) 95 ) ); 96 97 $body = wp_remote_retrieve_body( $request ); 98 $data = json_decode( $body, true ); 99 foreach ( $data as $datum ) { 100 update_post_meta( $datum['meta'], \Octify\Libs\OctifyApi::META_STATUS, 'error' ); 101 update_post_meta( $datum['meta'], \Octify\Libs\OctifyApi::META_NAME, array( 102 'error' => __( "Oops! Your image timed out, try again or contact your host to raise your timeout limit", octify()->domain ) 103 ) ); 104 } 105 } 106 107 public function cronSchedule( $schedules ) { 108 if ( ! isset( $schedules["5min"] ) ) { 109 $schedules["5min"] = array( 110 'interval' => 5 * 60, 111 'display' => __( 'Once every 5 minutes' ) 112 ); 113 } 114 115 return $schedules; 74 116 } 75 117 … … 145 187 wp_send_json_success(); 146 188 } 147 }148 149 public function getFreeKey() {150 if ( ! current_user_can( 'manage_options' ) ) {151 return;152 }153 $nonce = isset( $_POST['_octifyNonce'] ) ? $_POST['_octifyNonce'] : null;154 if ( ! wp_verify_nonce( $nonce, 'octify_getFreeKey' ) ) {155 return;156 }157 158 $email = isset( $_POST['email'] ) ? $_POST['email'] : null;159 if ( ! $email ) {160 //show error161 update_option( 'octifyErrorFlash', __( "Email can't be blank", octify()->domain ) );162 }163 164 $code = \Octify\Libs\OctifyApi::getAPIKey( $email );165 $res = \Octify\Libs\OctifyApi::activateCheck( $email, $code['code'] );166 if ( is_wp_error( $res ) ) {167 update_option( 'octifyErrorFlash', $res->get_error_message() );168 } else {169 update_option( 'octifyFlash', __( "Welcome to Octify!", octify()->domain ) );170 }171 172 wp_redirect( admin_url( 'upload.php?page=octify#' ) );173 189 } 174 190 … … 235 251 } 236 252 $file = get_attached_file( $id ); 237 unlink( $file );253 //unlink( $file ); 238 254 copy( $backupPath, $file ); 239 255 if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) { 240 256 include( ABSPATH . 'wp-admin/includes/image.php' ); 241 257 } 242 wp_generate_attachment_metadata( $id, $file );243 258 delete_post_meta( $id, \Octify\Libs\OctifyApi::META_NAME ); 244 259 delete_post_meta( $id, \Octify\Libs\OctifyApi::META_STATUS ); 260 //wp_generate_attachment_metadata( $id, $file ); 245 261 wp_send_json( array( 246 262 'status' => 1, … … 480 496 } 481 497 482 /**483 * Save settings484 */485 public function saveSettings() {486 $wpNonce = isset( $_POST['_octifyNonce'] ) ? $_POST['_octifyNonce'] : null;487 if ( is_null( $wpNonce ) ) {488 return;489 }490 if ( ! wp_verify_nonce( $wpNonce, 'octify_settings' ) ) {491 return;492 }493 494 $settings = octify()->getSettings();495 foreach ( $settings as $key => $val ) {496 if ( isset( $_POST[ $key ] ) ) {497 $settings[ $key ] = $_POST[ $key ];498 }499 }500 update_option( 'octify', $settings );501 update_option( 'octifyFlash', __( "Settings saved successfully", $this->domain ) );502 wp_redirect( admin_url( 'upload.php?page=octify' ) );503 exit;504 }505 506 public function activate() {507 $wpNonce = isset( $_POST['_octifyNonce'] ) ? $_POST['_octifyNonce'] : null;508 if ( is_null( $wpNonce ) ) {509 return;510 }511 if ( ! wp_verify_nonce( $wpNonce, 'octifyActivator' ) ) {512 return;513 }514 515 $email = sanitize_email( $_POST['email'] );516 $code = sanitize_key( $_POST['code'] );517 518 $res = \Octify\Libs\OctifyApi::activateCheck( $email, $code );519 if ( is_wp_error( $res ) ) {520 update_option( 'octifyErrorFlash', $res->get_error_message() );521 } else {522 update_option( 'octifyFlash', __( "WooHoo! You've just made an awesome decision523 thanks for choosing Octify!", octify()->domain ) );524 }525 526 wp_redirect( admin_url( 'upload.php?page=octify' ) );527 exit;528 }529 530 public function extend() {531 $wpNonce = isset( $_POST['_octifyNonce'] ) ? $_POST['_octifyNonce'] : null;532 if ( is_null( $wpNonce ) ) {533 return;534 }535 if ( ! wp_verify_nonce( $wpNonce, 'extendLicense' ) ) {536 return;537 }538 539 $email = sanitize_email( $_POST['email'] );540 $code = sanitize_key( $_POST['code'] );541 542 $res = \Octify\Libs\OctifyApi::activateCheck( $email, $code );543 if ( is_wp_error( $res ) ) {544 update_option( 'octifyErrorFlash', $res->get_error_message() );545 } else {546 update_option( 'octifyFlash', __( "WooHoo! You've just made an awesome decision547 thanks for choosing Octify!", octify()->domain ) );548 }549 550 wp_redirect( admin_url( 'upload.php?page=octify' ) );551 exit;552 }553 554 498 public function adminMenu() { 555 499 $svg = file_get_contents( $this->plugin_path . 'assets/octify-character-dashicon.svg' ); … … 569 513 570 514 if ( is_plugin_active( 'ocean-extra/ocean-extra.php' ) ) { 515 global $submenu; 516 $permalink = 'https://octify.io/?ref=nicolaslecocq'; 571 517 add_submenu_page( 'octify', __( "Go Pro", octify()->domain ), __( "Go Pro", octify()->domain ), 'manage_options', 'octify-pro', array( 572 518 &$this, 573 519 'goPro' 574 520 ) ); 521 $submenu['octify'][] = array( 'Go Pro', 'manage_options', $permalink ); 522 unset( $submenu['octify'][1] ); 575 523 } 576 524 … … 612 560 return; 613 561 } 614 615 562 unset( $parts[0] ); 616 563 $className = implode( '\\', $parts ); -
octify/trunk/View/dashboard2.php
r1859158 r1868268 75 75 $pendingImages = count( \Octify\Libs\OctifyApi::findImages( 'pending' ) ); 76 76 if ( $pendingImages > 0 ) { 77 $process = \Octify\ Libs\OctifyApi::calculateProgress();77 $process = \Octify\Controller\Compress::calPercent(); 78 78 ?> 79 79 <p> … … 86 86 value="<?php echo $process ?>" max="100"><?php echo $process ?>% 87 87 </progress> 88 <span class="octify-log"></span> 88 89 </div> 89 90 <?php … … 304 305 </div> 305 306 <br/> 306 <?php wp_nonce_field( ' extendLicense', '_octifyNonce' ) ?>307 <?php wp_nonce_field( 'octifyActivator', '_octifyNonce' ) ?> 307 308 <button class="button is-primary" type="submit">Submit</button> 308 309 </form> -
octify/trunk/assets/script.js
r1846576 r1868268 37 37 }, 38 38 success: function (data) { 39 $('.octify-progress').attr('value', data.data.percent).text(data.data.percent + '%'); 40 if (data.data.percent == 100) { 39 if (data.success == 1) { 40 $('.octify-progress').attr('value', data.data.percent).text(data.data.percent + '%'); 41 $('.octify-log').html(data.data.log); 42 if (data.data.is_done === true) { 43 location.reload(); 44 } else { 45 setTimeout(listen_bulk_status, 1000); 46 } 47 } else { 41 48 location.reload(); 42 } else {43 setTimeout(listen_bulk_status, 3000);44 49 } 45 50 } -
octify/trunk/readme.txt
r1860529 r1868268 1 1 === WordPress Image Compression Plugin - Octify === 2 2 Plugin Name: Octify 3 Version: 1. 1.43 Version: 1.2 4 4 Author: Octify 5 5 Author URI: https://octify.io/ … … 7 7 Tags: Image Compression, Image Optimisation, resize, optimise, performance, optimize, compress images, optimize images, optimise images, image optimization. 8 8 Tested up to: 4.9.5 9 Stable tag: 1. 1.49 Stable tag: 1.2 10 10 Requires PHP: 5.3 11 11 License: GPLv2
Note: See TracChangeset
for help on using the changeset viewer.