define_constants(); // Loaded Action add_action('plugins_loaded', array( $this, 'plugin_loaded' ), 10, 2); // Enqueue frontend scripts add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 999 ); add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 100 ); // trigger upon plugin activation/deactivation register_activation_hook( __FILE__, array( $this, 'plugin_activation' ) ); // Action link add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); } /** * Initialization */ public static function init(){ static $instance = false; if ( ! $instance ) { $instance = new self(); } return $instance; } /** * Define the required plugin constants * * @return void */ public function define_constants() { define( 'ALD_PLUGIN_VERSION', self::version ); define( 'ALD_PLUGIN_FILE', __FILE__ ); define( 'ALD_PLUGIN_PATH', __DIR__ ); define( 'ALD_PLUGIN_URL', plugin_dir_url( ALD_PLUGIN_FILE ) ); define( 'ALD_PLUGIN_ASSETS', ALD_PLUGIN_URL . 'assets' ); // GO PRO URL define( 'ALD_GOPRO_URL', 'https://addonmaster.com/load-more-anything/?utm_source=dashboard&utm_medium=popuptop&utm_campaign=wpuser' ); } /** * Plugin Loaded Action * * @return void */ function plugin_loaded() { require_once( dirname( __FILE__ ) . '/inc/ald-functions.php' ); require_once( dirname( __FILE__ ) . '/admin/functions.php' ); require_once( dirname( __FILE__ ) . '/admin/Menu.php' ); } /** * Enqueue Frontend Scripts */ function enqueue_scripts() { $jquery_dep = get_ald_options('disable_jquery_dep') == 'on' ? [] : ['jquery']; wp_enqueue_style( 'ald-styles', ALD_PLUGIN_ASSETS . '/styles.min.css', [], ALD_PLUGIN_VERSION ); wp_enqueue_script( 'ald-scripts', ALD_PLUGIN_ASSETS . '/scripts.js', $jquery_dep, ALD_PLUGIN_VERSION, true ); wp_localize_script( 'ald-scripts', 'ald_params', array( 'nonce' => wp_create_nonce( 'ald_nonce' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'ald_pro' => ( defined('ALD_PRO_PLUGIN_VERSION') ) ? '1' : '0', ) ); } /** * Enqueue admin script */ function admin_scripts( $hook ) { if ( 'toplevel_page_ald_setting' != $hook ) { return; } wp_register_style( 'ald-admin-styles', ALD_PLUGIN_ASSETS . '/admin.min.css', null, ALD_PLUGIN_VERSION ); wp_register_script( 'ald-admin-scripts', ALD_PLUGIN_ASSETS . '/admin.min.js', array('jquery'), ALD_PLUGIN_VERSION, true ); // Ajax Params wp_localize_script( 'ald-admin-scripts', 'alda_params', array( 'nonce' => wp_create_nonce( 'ald_nonce' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'ald_pro' => ( defined('ALD_PRO_PLUGIN_VERSION') ) ? '1' : '0', ) ); } /** * Plugin Activation */ function plugin_activation() { update_option( 'ald_installed', time() ); update_option( 'ald_plugin_version', ALD_PLUGIN_VERSION ); } /** * Adds plugin action links. * * @since 1.0.0 * @version 4.0.0 */ function plugin_action_links( $links ) { if( !defined('ALD_PRO_PLUGIN_VERSION') ){ $plugin_links[] = '★' . esc_html__( 'GO PRO', 'ajax-load-more-anything' ) . ''; } $plugin_links[] = '' . esc_html__( 'Settings', 'ajax-load-more-anything' ) . ''; return array_merge( $plugin_links, $links ); } } /** * Initialize plugin */ function ajax_load_more_anything(){ return Ajax_Load_More_Anything::init(); } // Let's start it ajax_load_more_anything(); /** * Initialize the plugin tracker * * @return void */ function ama_appsero_init_tracker_ajax_load_more_anything() { if ( ! class_exists( 'Appsero\Client' ) ) { require_once __DIR__ . '/appsero/src/Client.php'; } $client = new Appsero\Client( '7e201c93-ae5f-4a3a-8ead-d1ccf4ad5e30', 'Load More Anything', __FILE__ ); // Active insights $client->insights()->init(); } ama_appsero_init_tracker_ajax_load_more_anything();