|

'' . __('Settings', 'ampforwp') . ' | ' . __('Premium Support', 'ampforwp') . ''); include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'amp/amp.php' ) ) { //if parent plugin is activated $actions = array_merge( $actions, $settings ); } else{ if(is_plugin_active( 'amp/amp.php' )){ $actions = array_merge( $actions, $settings ); }else{ $please_activate_parent_plugin = array('Please Activate Parent plugin' => '' . __('Action Required: Continue Installation', 'ampforwp') . ''); $actions = array_merge( $please_activate_parent_plugin,$actions ); } } } return $actions; } } } // is_admin() closing if ( ! class_exists( 'Ampforwp_Init', false ) ) { class Ampforwp_Init { public function __construct(){ // Load Files required for the plugin to run require AMPFORWP_PLUGIN_DIR .'/includes/includes.php'; require AMPFORWP_PLUGIN_DIR .'/classes/class-init.php'; new Ampforwp_Loader; } } } /* * Start the plugin. * Gentlemen start your engines */ function ampforwp_plugin_init() { if ( defined( 'AMP__FILE__' ) && defined('AMPFORWP_PLUGIN_DIR') ) { new Ampforwp_Init; } } add_action('init','ampforwp_plugin_init',9); function ampforwp_page_template_redirect() { global $redux_builder_amp; if($redux_builder_amp['amp-mobile-redirection']){ if ( wp_is_mobile() ) { if ( ampforwp_is_amp_endpoint() ) { return; } else { if ( is_home() ) { wp_redirect( trailingslashit( esc_url( home_url() ) ) .'?'. AMP_QUERY_VAR , 301 ); exit(); } elseif ( is_archive() ) { return ; } else { wp_redirect( trailingslashit( esc_url( ( get_permalink( $id ) ) ) ) . AMP_QUERY_VAR , 301 ); exit(); } } } } } add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 ); add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 ); function ampforwp_page_template_redirect_archive() { if ( is_archive() || is_404() ) { if( ampforwp_is_amp_endpoint() ) { global $wp; $archive_current_url = add_query_arg( '', '', home_url( $wp->request ) ); $archive_current_url = trailingslashit($archive_current_url ); if (is_404() ) { $archive_current_url = dirname($archive_current_url); } wp_redirect( esc_url( $archive_current_url ) , 301 ); exit(); } } } // Add Custom Rewrite Rule to make sure pagination & redirection is working correctly function ampforwp_add_custom_rewrite_rules() { add_rewrite_rule( 'amp/page/([0-9]{1,})/?$', 'index.php?amp&paged=$matches[1]', 'top' ); } add_action( 'init', 'ampforwp_add_custom_rewrite_rules' ); function ampforwp_is_amp_endpoint() { return false !== get_query_var( 'amp', false ); }