define_constants(); $this->includes(); $this->init_hooks(); } /** * Define Gutenify Constants. */ private function define_constants() { $this->define( 'GUTENIFY_PLUGIN_FILE', __FILE__ ); $this->define( 'GUTENIFY_ABSPATH', dirname( __FILE__ ) . '/' ); $this->define( 'GUTENIFY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); $this->define( 'GUTENIFY_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); $this->define( 'GUTENIFY_VERSION', $this->version ); } /** * Hook into actions and filters. * * @since 0.0.1 * @return void */ private function init_hooks() { Gutenify_Blocks_Loader::init(); add_action( 'init', array( $this, 'set_script_translations' ) ); } /** * Include required core files used in admin and on the frontend. * * @return void */ function includes() { include_once('inc/class-helpers.php'); include_once('inc/class-blocks-loader.php'); } /** * Define constants. */ public function define( $name, $value ) { if ( ! defined( $name ) ) { define( $name, $value ); } } /** * What type of request is this? * * @param string $type admin, ajax, cron or frontend. * @return bool */ private function is_request( $type ) { switch ( $type ) { case 'admin' : return is_admin(); case 'ajax' : return defined( 'DOING_AJAX' ); case 'cron' : return defined( 'DOING_CRON' ); case 'frontend' : return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ); } } function set_script_translations() { wp_set_script_translations( 'gutenify-script', 'gutenify', plugin_dir_path( __FILE__ ) . 'i18n/languages' ); } } endif; /** * Main instance of gutenify. * * Returns the main instance of Gutenify to prevent the need to use globals. * * @since 0.0.1 * @return gutenify */ function gutenify() { return Gutenify::instance(); } // Start gutenify. gutenify();