Fix the page slurp

This commit is contained in:
Mike Jolley 2013-03-10 14:33:27 +00:00
parent 2cb9363c22
commit 6f238650d1
5 changed files with 60 additions and 48 deletions

View File

@ -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' );
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' ) );

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -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;
});

View File

@ -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 "<div id='mijireh_notice' class='mijireh-info alert-message info' data-alert='alert'>";
echo "<h2>Slurp your custom checkout page!</h2>";

View File

@ -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.