client = new ThisBig_Client(); $this->connect = new ThisBig_Connect( $this->client ); $this->slot = new ThisBig_Slot(); $this->settings = new ThisBig_Settings( $this->connect, $this->client ); $this->sync = new ThisBig_Sync( $this->client ); $this->rest = new ThisBig_Rest( $this->client, $this->sync ); $this->connect->register(); $this->slot->register(); $this->settings->register(); $this->sync->register(); $this->rest->register(); add_action( 'init', array( $this, 'load_textdomain' ) ); add_action( 'plugins_loaded', array( $this, 'load_woocommerce' ) ); } /** Where the plugin's own translations are: languages/, beside the .pot. */ public static function languages() { return THISBIG_DIR . 'languages'; } /** * Ships languages/thisbig-.mo for locales WordPress.org's packs don't cover yet; * a pack for the same locale wins. Script translations load from the same folder. */ public function load_textdomain() { load_plugin_textdomain( 'thisbig', false, dirname( plugin_basename( THISBIG_FILE ) ) . '/languages' ); // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound -- the plugin ships its languages before WordPress.org's language packs have them; a pack, once there, is loaded first. } /** * The check every admin-post.php action starts with: the right capability, else * a 403 saying why, and its own nonce. */ public static function admin_post( $capability, $action, $refusal ) { if ( ! current_user_can( $capability ) ) { wp_die( esc_html( $refusal ), 403 ); } check_admin_referer( $action ); } /** Daily from a day from now, unless it already recurs; a one-off run due sooner doesn't count. */ public static function daily( $hook ) { if ( false === wp_get_schedule( $hook ) ) { wp_schedule_event( time() + DAY_IN_SECONDS, 'daily', $hook ); } } public function load_woocommerce() { if ( ! class_exists( 'WooCommerce' ) ) { return; } require_once THISBIG_DIR . 'includes/woocommerce/class-thisbig-kinds.php'; require_once THISBIG_DIR . 'includes/woocommerce/class-thisbig-woocommerce.php'; require_once THISBIG_DIR . 'includes/woocommerce/class-thisbig-stated-sizes.php'; $this->kinds = new ThisBig_Kinds( $this->client ); $this->woocommerce = new ThisBig_WooCommerce( $this->slot, $this->kinds ); $this->woocommerce->register(); $this->sync->set_source( array( $this->woocommerce, 'catalogue' ) ); } }