init_hooks(); } /** * Init Hooks * * @return void */ public function init_hooks() { $m = new \AB_FONTS_MANAGER(); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); add_action( 'wp', array( $m, 'generate_assets' ) ); add_action('wp_head', array($this, 'generate_stylesheet'), 80); } /** * Affiliate Blocks * * @return void */ public function get_affiliate_blocks() { return array(); } /** * Load Frontend assets. * * @return void */ public function enqueue_styles() { wp_enqueue_style( 'affiliatex-public', // Handle. plugin_dir_url( AFFILIATEX_PLUGIN_FILE ) . '/app/build/publicCSS.css' ); $m = new \AB_FONTS_MANAGER(); $m->load_dynamic_google_fonts(); } /** * Generates stylesheet and appends in head tag. * * @since 0.0.1 */ public function generate_stylesheet() { $m = new \AB_FONTS_MANAGER(); $stylesheet = $m::$stylesheet; $this_post = array(); if ( is_null( $stylesheet ) || '' === $stylesheet ) { return; } if (is_single() || is_page() || is_404()) { global $post; $this_post = $post; $this->_generate_stylesheet($this_post); if (!is_object($post)) { return; } } elseif (is_archive() || is_home() || is_search()) { global $wp_query; foreach ($wp_query as $post) { $this->_generate_stylesheet($post); } } } /** * Generates stylesheet in loop. * * @param object $this_post Current Post Object. * @since 1.7.0 */ public function _generate_stylesheet() { $m = new \AB_FONTS_MANAGER(); $stylesheet = $m::$stylesheet; if ( is_null( $stylesheet ) || '' === $stylesheet ) { return; } ob_start(); ?>