Post Shortcodes

// Est. Reading Time $reading_speed = 200; // 200 words per minute $content = get_post_field( ‘post_content’, get_the_id() ); $word_count = str_word_count( strip_tags( $content ) ); $reading_time = ceil( $word_count / $reading_speed ); function post_read_time_shortcode($atts) { echo ‘ Estimated reading time:…Continue reading

NMDFX Admin bar, Dashboard, Edits & Custom CSS

/* HIDE Monster Icon */ .monsterinsights-quick-links, .monsterinsights-float-right { display: none!important; } #monsterinsights_reports_widget { padding: 50px 0; } #monsterinsights_reports_widget .ui-sortable-handle { display: none!important; } /* Replace plugin logo */ .monsterinsights-logo-area img { content: url(‘https://www.coverings.com/wp-content/uploads/2024/11/Nation-Media-Dashboard-FX.png’); /* Adjust size if needed */ width:…Continue reading

Typography Enqueue

function typography_enqueue_styles() { // Enqueue Typeboost.css from Cloudflare CDN wp_enqueue_style(‘typeboost-css’, ‘https://cdnjs.cloudflare.com/ajax/libs/typeboost/1.0.0/typeboost.css’, array(), ‘1.0.0’); // Enqueue webfontloader.js from Cloudflare CDN wp_enqueue_script(‘webfontloader’, ‘https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js’, array(), ‘1.6.28’, true); } add_action(‘wp_enqueue_scripts’, ‘typography_enqueue_styles’);Continue reading

Redirect from Array

function custom_redirect_old_new_urls() { $redirect_urls = array( ‘/oldpage/’ => ‘/newpage/’, ‘/oldpage1/’ => ‘/newpage1/’, // Add more URLs here ); $request_uri = home_url( add_query_arg( array(), $_SERVER[‘REQUEST_URI’] ) ); foreach ( $redirect_urls as $old_url => $new_url ) { if ( untrailingslashit( $request_uri )…Continue reading

Google Tag Manager (copy)

(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’: new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src= ‘https://www.googletagmanager.com/gtm.js?id=’+i+dl;f.parentNode.insertBefore(j,f); })(window,document,’script’,’dataLayer’,’GTM-W23H2FM’);Continue reading

修改WP Memory等參數

// 設定 WordPress 記憶體限制 define(‘WP_MEMORY_LIMIT’, ‘256M’); define(‘WP_MAX_MEMORY_LIMIT’, ‘512M’); // 設定 PHP 執行層的上傳限制 @ini_set(‘upload_max_filesize’, ’64M’); @ini_set(‘post_max_size’, ’64M’); @ini_set(‘max_execution_time’, ‘300’);Continue reading