PluginProbe
Omise Payments / 3.9
Omise Payments v3.9
7.2.1 7.2.0 trunk 1.2.3 3.0 3.1 3.10 3.11 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.10 4.11 4.12 4.13 4.14 4.15 4.15.1 All 97 releases
omise / includes / class-omise-admin.php

class-omise-admin.php in Omise Payments 3.9, at includes/class-omise-admin.php

91 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) or die( "No direct script access allowed." );
3
4 if ( ! class_exists( 'Omise_Admin' ) ) {
5 class Omise_Admin {
6 /**
7 * The Omise Instance.
8 *
9 * @var \Omise_Admin
10 */
11 protected static $the_instance;
12
13 /**
14 * @return \Omise_Admin The instance.
15 */
16 public static function get_instance() {
17 if ( ! self::$the_instance ) {
18 self::$the_instance = new self();
19 }
20
21 return self::$the_instance;
22 }
23
24 /**
25 * @since 3.3
26 */
27 public function init() {
28 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/admin/class-omise-page-settings.php';
29
30 $this->register_admin_menu();
31 $this->register_woocommerce_filters();
32 }
33
34 /**
35 * Register Omise's custom menu to WordPress admin menus.
36 */
37 public function register_admin_menu() {
38 add_action( 'admin_menu', array( $this, 'wordpress_hook_admin_menu' ) );
39 }
40
41 /**
42 * Callback to $this::register_admin_menu() method.
43 * Register Omise's custom menu to WordPress admin menus.
44 */
45 public function wordpress_hook_admin_menu() {
46 add_menu_page( 'Omise', 'Omise', 'manage_options', 'omise', array( $this, 'page_settings') );
47
48 add_submenu_page( 'omise', __( 'Omise Settings', 'omise' ), __( 'Settings', 'omise' ), 'manage_options', 'omise-settings', array( $this, 'page_settings') );
49 }
50
51 /**
52 * Render Omise Setting page.
53 */
54 public function page_settings() {
55 Omise_Page_Settings::render();
56 }
57
58 /**
59 * @since 3.3
60 */
61 public function register_woocommerce_filters() {
62 add_filter( 'woocommerce_order_actions', array( $this, 'woocommerce_filter_order_actions' ) );
63 }
64
65 /**
66 * Callback to $this::register_woocommerce_filters() method.
67 *
68 * @since 3.3
69 *
70 * @param array $order_actions
71 *
72 * @return array
73 */
74 public function woocommerce_filter_order_actions( $order_actions ) {
75 global $theorder;
76
77 /** backward compatible with WooCommerce v2.x series **/
78 $payment_method = version_compare( WC()->version, '3.0.0', '>=' ) ? $theorder->get_payment_method() : $theorder->payment_method;
79
80 if ( 'omise' === $payment_method ) {
81 $order_actions[ $payment_method . '_charge_capture'] = __( 'Omise: Capture this order', 'omise' );
82 }
83
84 $order_actions[ $payment_method . '_sync_payment'] = __( 'Omise: Manual sync payment status', 'omise' );
85
86 return $order_actions;
87 }
88 }
89 }
90 ?>
91