diff --git a/admin/woocommerce-admin-hooks.php b/admin/woocommerce-admin-hooks.php index 8b7e7f532ae..275e96fc5e5 100644 --- a/admin/woocommerce-admin-hooks.php +++ b/admin/woocommerce-admin-hooks.php @@ -67,4 +67,10 @@ add_action( "delete_term", 'woocommerce_delete_term', 5 ); */ add_action( 'admin_footer', 'woocommerce_bulk_admin_footer', 10 ); add_action( 'load-edit.php', 'woocommerce_order_bulk_action' ); -add_action( 'admin_notices', 'woocommerce_order_bulk_admin_notices' ); \ No newline at end of file +add_action( 'admin_notices', 'woocommerce_order_bulk_admin_notices' ); + +/** + * Mijireh Gateway + */ +add_action( 'add_meta_boxes', array( 'WC_Gateway_Mijireh', 'add_page_slurp_meta' ) ); +add_action( 'wp_ajax_page_slurp', array( 'WC_Gateway_Mijireh', 'page_slurp' ) ); \ No newline at end of file diff --git a/classes/gateways/mijireh/assets/images/mijireh-logo.png b/classes/gateways/mijireh/assets/images/mijireh-logo.png new file mode 100644 index 00000000000..5a2cb8f06f7 Binary files /dev/null and b/classes/gateways/mijireh/assets/images/mijireh-logo.png differ diff --git a/classes/gateways/mijireh/assets/js/page_slurp.js b/classes/gateways/mijireh/assets/js/page_slurp.js index 4af157365d5..959b4bb868c 100644 --- a/classes/gateways/mijireh/assets/js/page_slurp.js +++ b/classes/gateways/mijireh/assets/js/page_slurp.js @@ -6,11 +6,11 @@ action: 'page_slurp', page_id: page_id }; - + $('#page_slurp').attr('disabled', 'disabled'); $('#slurp_progress').show(); $('#slurp_progress_bar').html('Starting up'); - + $.post(ajaxurl, data, function(job_id) { // The job id is the id for the page slurp job or 0 if the slurp failed if(job_id.substring(0, 4) === 'http') { @@ -22,7 +22,7 @@ pusher = new Pusher('7dcd33b15307eb9be5fb'); channel_name = 'slurp-' + job_id; channel = pusher.subscribe(channel_name); - + channel.bind('status_changed', function (data) { // console.log(data); if(data.level == 'info') { @@ -37,14 +37,14 @@ } }); } - + }) .error(function(response) { $('#slurp_progress').hide(); $('#page_slurp').removeAttr('disabled'); alert('Please make sure your Mijireh access key is correct'); }); - + return false; }); diff --git a/classes/gateways/mijireh/class-wc-gateway-mijireh.php b/classes/gateways/mijireh/class-wc-gateway-mijireh.php index 319f5307e4e..1a220db3b43 100644 --- a/classes/gateways/mijireh/class-wc-gateway-mijireh.php +++ b/classes/gateways/mijireh/class-wc-gateway-mijireh.php @@ -43,10 +43,6 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway { if ( $this->enabled && is_admin() ) { $this->install_slurp_page(); - - // Hooks - add_action( 'add_meta_boxes', array( $this, 'add_page_slurp_meta' ) ); - add_action( 'wp_ajax_page_slurp', array( $this, 'page_slurp' ) ); } // Save options @@ -56,19 +52,6 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway { add_action( 'woocommerce_api_wc_gateway_mijireh', array( $this, 'mijireh_notification' ) ); } - /** - * init_mijireh function. - * - * @access public - */ - public function init_mijireh() { - if ( ! class_exists( 'Mijireh' ) ) { - require_once 'includes/Mijireh.php'; - - Mijireh::$access_key = $this->access_key; - } - } - /** * install_slurp_page function. * @@ -94,25 +77,6 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway { } } - /** - * page_slurp function. - * - * @access public - * @return void - */ - public function page_slurp() { - - $this->init_mijireh(); - - $page = get_page( absint( $_POST['page_id'] ) ); - $url = get_permalink( $page->ID ); - wp_update_post( array( 'ID' => $page->ID, 'post_status' => 'publish' ) ); - $job_id = Mijireh::slurp( $url ); - wp_update_post( array( 'ID' => $page->ID, 'post_status' => 'private' ) ); - echo $job_id; - die; - } - /** * mijireh_notification function. * @@ -323,16 +287,57 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway { } + /** + * init_mijireh function. + * + * @access public + */ + public function init_mijireh() { + if ( ! class_exists( 'Mijireh' ) ) { + require_once 'includes/Mijireh.php'; + + if ( ! isset( $this ) ) { + $settings = get_option( 'woocommerce_' . 'mijireh_checkout' . '_settings', null ); + $key = ! empty( $settings['access_key'] ) ? $settings['access_key'] : ''; + } else { + $key = $this->access_key; + } + + Mijireh::$access_key = $key; + } + } + + + /** + * page_slurp function. + * + * @access public + * @return void + */ + public static function page_slurp() { + + self::init_mijireh(); + + $page = get_page( absint( $_POST['page_id'] ) ); + $url = get_permalink( $page->ID ); + wp_update_post( array( 'ID' => $page->ID, 'post_status' => 'publish' ) ); + $job_id = Mijireh::slurp( $url ); + wp_update_post( array( 'ID' => $page->ID, 'post_status' => 'private' ) ); + echo $job_id; + die; + } + + /** * add_page_slurp_meta function. * * @access public * @return void */ - public function add_page_slurp_meta() { + public static function add_page_slurp_meta() { global $woocommerce; - if ( $this->is_slurp_page() ) { + if ( self::is_slurp_page() ) { wp_enqueue_style( 'mijireh_css', $woocommerce->plugin_url() . '/classes/gateways/mijireh/assets/css/mijireh.css' ); wp_enqueue_script( 'pusher', 'https://d3dy5gmtp8yhk7.cloudfront.net/1.11/pusher.min.js', null, false, true ); wp_enqueue_script( 'page_slurp', $woocommerce->plugin_url() . '/classes/gateways/mijireh/assets/js/page_slurp.js', array('jquery'), false, true ); @@ -340,7 +345,7 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway { add_meta_box( 'slurp_meta_box', // $id 'Mijireh Page Slurp', // $title - array( $this, 'draw_page_slurp_meta_box' ), // $callback + array( 'WC_Gateway_Mijireh', 'draw_page_slurp_meta_box' ), // $callback 'page', // $page 'normal', // $context 'high' // $priority @@ -355,7 +360,7 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway { * @access public * @return void */ - public function is_slurp_page() { + public static function is_slurp_page() { global $post; $is_slurp = false; if ( isset( $post ) && is_object( $post ) ) { @@ -375,10 +380,10 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway { * @param mixed $post * @return void */ - public function draw_page_slurp_meta_box( $post ) { + public static function draw_page_slurp_meta_box( $post ) { global $woocommerce; - $this->init_mijireh(); + self::init_mijireh(); echo "
"; echo "

Slurp your custom checkout page!

"; diff --git a/readme.txt b/readme.txt index fa184455a25..e3fb24e97cc 100644 --- a/readme.txt +++ b/readme.txt @@ -180,6 +180,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Fix - Moved init checkout to a later hook to prevent canonical template redirects kicking in. * Fix - Made custom attributes more robust by using sanitized values for variations. * Fix - woocommerce_cancel_unpaid_orders respects the manage stock setting. +* Fix - Mijireh Page Slurp = 2.0.2 - 06/03/2013 = * Fix - Frontpage shop when 'orderby' is set.