' . __( 'Settings' ) . ''; array_push( $links, $settings_link ); return $links; } $linknya = plugin_basename( __FILE__ ); add_filter( "plugin_action_links_$linknya", 'amp_by_zaenu_settings_link' ); // end of hook menu // inject meta tag function amp_by_zaenu_injek_head() { if ( is_single() ) { echo ''; } } add_action('wp_head', 'amp_by_zaenu_injek_head'); // enf of inject meta tag // init end point function amp_by_zaenu_endpoint() { add_rewrite_endpoint(AMP_QUERY_VAR, EP_PERMALINK); } add_action( 'init', 'amp_by_zaenu_endpoint' ); // end of init end point // init amp page add_filter( 'template_include', 'amp_by_zaenu_template_init', 99 ); function amp_by_zaenu_template_init( $template ) { if( get_query_var( AMP_QUERY_VAR, false ) !== false ) { if ( is_single() ) { $template = get_template_directory().'/amp-single.php'; } } return $template; } // end of init amp page // init script function amp_by_zaenu_add_script(){ wp_enqueue_media(); wp_enqueue_script('zaenu-uploader',plugin_dir_url( __FILE__ ).'js/uploader.js', array('jquery'), false, true ); wp_register_script( 'zaenu-aplot', plugin_dir_url( __FILE__ ).'js/aplot.js' ); wp_enqueue_script( 'zaenu-aplot' ); } add_action('admin_enqueue_scripts', 'amp_by_zaenu_add_script'); // end of init script // simple excerpt function amp_by_zaenu__cuplikan($charlength) { $excerpt = get_the_excerpt(); $charlength++; if ( mb_strlen( $excerpt ) > $charlength ) { $subex = mb_substr( $excerpt, 0, $charlength - 5 ); $exwords = explode( ' ', $subex ); $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); if ( $excut < 0 ) { echo mb_substr( $subex, 0, $excut ); } else { echo $subex; } echo ''; } else { echo $excerpt; } } // end of simple excerpt // remove paging add_action( 'the_post', 'amp_by_zaenu_removing_nex', 99); function amp_by_zaenu_removing_nex ( $post ) { if ( (get_query_var( AMP_QUERY_VAR, false ) !== false) && (false !== strpos( $post->post_content, '' )) ) { $GLOBALS['pages'] = [ $post->post_content ]; $GLOBALS['numpages'] = 0; $GLOBALS['multipage'] = false; } }; // end of remove paging // removing caption add_filter( 'img_caption_shortcode', 'amp_by_zaenu_removing_caption', 10, 3 ); function amp_by_zaenu_removing_caption( $output, $attr, $content ) { if ( is_feed() ) return $output; $defaults = array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ); $attr = shortcode_atts( $defaults, $attr ); if( get_query_var( AMP_QUERY_VAR, false ) !== false ) { if ( 1 > $attr['width'] || empty( $attr['caption'] ) ) return $content; $attributes = ( !empty( $attr['id'] ) ? ' id="' . esc_attr( $attr['id'] ) . '"' : '' ); $attributes .= ' class="sld wp-caption ' . esc_attr( $attr['align'] ) . '"'; $attributes .= ' style="width: ' . esc_attr( $attr['width'] ) . 'px"'; $output = ''; $output .= do_shortcode( $content ); $output .= '

' . $attr['caption'] . '

'; $output .= ''; return $output; } } // end of removing caption // admin setting page function amp_by_zaenu_admin() { if($_POST['zaenu_submit'] && isset($_POST['zaenu_submit'])) { update_option('zaenu_logo', $_POST['zaenu_logo']); update_option('zaenu_icon', $_POST['zaenu_icon']); update_option('zaenu_analytics', $_POST['zaenu_analytics']); update_option('zaenu_adsenseid', $_POST['zaenu_adsenseid']); update_option('zaenu_adsenseslot', $_POST['zaenu_adsenseslot']); echo '

Updated!

'; $logos = get_option('zaenu_logo'); $icons = get_option('zaenu_icon'); $analytics = get_option('zaenu_analytics'); $adsid = get_option('zaenu_adsenseid'); $adslot = get_option('zaenu_adsenseslot'); if($wrote = fopen(get_template_directory().'/amp-single.php','w')){ $fixreplace1 = "#((?:]+>\s*)?]+>(?:\s*)?)(.*)#is"; $fixreplace2 = '#(<[a-z ]*)(style=("|\\\')(.*?)("|\\\'))([a-z ]*>)#'; $fixreplace3 = "Konten Video tersedia di ".get_the_title().""; $fixreplace4 = "'\\\\1\\\\6'"; require_once( zaenu_dir . 'amp-single.php' ); fwrite($wrote, $konten); fclose($wrote); } }; $zaenu_logo = get_option('zaenu_logo'); $zaenu_icon = get_option('zaenu_icon'); $zaenu_analytics = get_option('zaenu_analytics'); $zaenu_adsenseid = get_option('zaenu_adsenseid'); $zaenu_adsenseslot = get_option('zaenu_adsenseslot'); ?>
Important! Don't forget to update your permalink first! Click Here!
" . __( 'AMP SETTING', 'amp_by_zaenu_admin' ) . ""; ?>