| 1 |
<?php |
| 2 |
|
| 3 |
namespace Better_Payment\Lite; |
| 4 |
|
| 5 |
use Better_Payment\Lite\Admin\Better_Payment_Settings; |
| 6 |
use Better_Payment\Lite\Admin\Elementor\Better_Payment_Widget; |
| 7 |
use Better_Payment\Lite\Admin\Elementor\Widget; |
| 8 |
use Better_Payment\Lite\Admin\Menu; |
| 9 |
use Better_Payment\Lite\Classes\Better_Payment_Helper; |
| 10 |
use Better_Payment\Lite\Classes\Export; |
| 11 |
|
| 12 |
/** |
| 13 |
* Exit if accessed directly |
| 14 |
*/ |
| 15 |
if (!defined('ABSPATH')) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* The admin class |
| 21 |
* |
| 22 |
* @since 0.0.1 |
| 23 |
*/ |
| 24 |
class Admin extends Controller{ |
| 25 |
|
| 26 |
// Check if pro is enabled |
| 27 |
protected $pro_enabled; |
| 28 |
|
| 29 |
/** |
| 30 |
* Initialize the class |
| 31 |
* |
| 32 |
* @since 0.0.1 |
| 33 |
*/ |
| 34 |
public function __construct() { |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
public function init(){ |
| 39 |
$this->pro_enabled = apply_filters('better_payment/pro_enabled', false); |
| 40 |
|
| 41 |
if ( defined( 'ELEMENTOR_VERSION' ) ) { |
| 42 |
new Better_Payment_Settings(); |
| 43 |
} |
| 44 |
|
| 45 |
if (!did_action('elementor/loaded')) { |
| 46 |
$notice = new Better_Payment_Helper(); |
| 47 |
$notice->elementor_not_loaded(); |
| 48 |
} |
| 49 |
|
| 50 |
if (did_action('elementor/loaded')) { |
| 51 |
add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Add settings page link on plugins page |
| 57 |
* |
| 58 |
* @param array $links |
| 59 |
* @param string $file |
| 60 |
* |
| 61 |
* @return array |
| 62 |
* @since 0.0.1 |
| 63 |
*/ |
| 64 |
public function plugin_actions_links($links, $file) { |
| 65 |
$better_payment_plugin = plugin_basename(BETTER_PAYMENT_FILE); |
| 66 |
|
| 67 |
if ($file == $better_payment_plugin && current_user_can('manage_options')) { |
| 68 |
$links[] = sprintf('<a href="%s">%s</a>', admin_url("admin.php?page=better-payment-settings"), __('Settings', 'better-payment')); |
| 69 |
|
| 70 |
if ( ! $this->pro_enabled ) { |
| 71 |
$links[] = sprintf('<a href="https://wpdeveloper.com/in/upgrade-better-payment-pro" target="_blank" style="color: #7561F8; font-weight: bold;">' . __('Go Pro', 'better-payment') . '</a>'); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
return $links; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Dispatch and bind actions |
| 80 |
* |
| 81 |
* @return void |
| 82 |
* @since 0.0.1 |
| 83 |
*/ |
| 84 |
public static function dispatch_actions( ) { |
| 85 |
$menuObj = new Menu(); |
| 86 |
$menuObj->init(); |
| 87 |
|
| 88 |
$bpElementorWidgetObj = new Widget(); |
| 89 |
|
| 90 |
$bpExportObj = new Export(); |
| 91 |
|
| 92 |
// Handle select2 ajax search |
| 93 |
add_action('wp_ajax_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']); |
| 94 |
add_action('wp_ajax_nopriv_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']); |
| 95 |
|
| 96 |
add_action('wp_ajax_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']); |
| 97 |
add_action('wp_ajax_nopriv_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']); |
| 98 |
|
| 99 |
// Elements |
| 100 |
add_action('elementor/controls/controls_registered',[$bpElementorWidgetObj, 'register_controls']); |
| 101 |
|
| 102 |
//Page: Transactions |
| 103 |
add_action('wp_ajax_better-payment-transactions-export',[$bpExportObj, 'export_transactions']); |
| 104 |
} |
| 105 |
} |
| 106 |
|