Tag: wordpress

  • Troubleshoot: Fix Internet Explorer 8 mess up WordPress themes

    Use this service to test the pages https://netrenderer.com

    https://developer.microsoft.com/en-us/microsoft-edge/

    How to fix Internet Explorer 8 messing up WordPress themes

    Download virtual machines
    Test Microsoft Edge and versions of IE8 through IE11 using free virtual machines you download and manage locally.
    https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

    https://developer.microsoft.com/en-us/microsoft-edge/tools/screenshots/

  • WordPress: Responsive video (mp4 video inserted from media library)

    Changed the wordpress wp-includes/media.php file. Probably not the best way to do this.
    Ref: https://codex.wordpress.org/Video_Shortcode

    At around line 2504, comment out the following:

    $html_atts = array(
    	'class'    => $atts['class'],
    	'id'       => sprintf( 'video-%d-%d', $post_id, $instance ),
    	'width'    => $atts['width'],
    	//'width'    => absint( $atts['width'] ),
    	//'height'   => absint( $atts['height'] ),
    	'poster'   => esc_url( $atts['poster'] ),
    	'loop'     => wp_validate_boolean( $atts['loop'] ),
    	'autoplay' => wp_validate_boolean( $atts['autoplay'] ),
    	'preload'  => $atts['preload'],
    );

    At around line 2565, comment out the following and add code:

    if ( ! empty( $atts['width'] ) ) {
    //	$width_rule = sprintf( 'width: %dpx; ', $atts['width'] );
    	$width_rule = '';
    }

    Added additional CSS styles to make it work.

    video {
      width: 100%    !important;
      height: auto   !important;
    }

    Source: https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php
    https://coolestguidesontheplanet.com/videodrome/youtube/

    While we’re at it, also centralize the video with this CSS

    .wp-video { display:block; margin: 0 auto; }
  • WordPress: Redirect after Login on WordPress

    Source: http://stackoverflow.com/questions/8127453/redirect-after-login-on-wordpress

    Add the following to child theme’s functions.php

    function admin_default_page() {
    return ‘/new-dashboard-url’;
    }

    add_filter(‘login_redirect’, ‘admin_default_page’);

  • Easy Fancybox: Solution for Iframe no-scroll issue in mobile

    Source: https://alucard-blog.blogspot.sg/2016/06/how-to-fix-fancy-boxeasy-fancybox.html

    How to fix fancy box scroll not working in mobile. Using wordpress plugin https://wordpress.org/plugins/easy-fancybox/

    In Easy Fancybox, you will see these 2 lines in the jquery.fancybox-1.3.7.js: (do a folder search for id=”fancybox-content” to get better idea of how it looks like)

    <div id=”fancybox-content”……..>
    <iframe id=”fancybox-frame” name……………

    Apply to fancybox-content, not fancybox-frame

    So in your custom/child theme CSS, it should be:

    #fancybox-content{
    overflow: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    }

  • WordPress: Disable product arrow pop-out (woocommerce, custom posts, Jupiter theme)

    Source: https://wordpress.org/support/topic/woocommerce-disable-product-arrow-pop-out

    Affects all custom posts

    Question:

    Hi,

    I’m using WooCommerce (latest) with my Jupiter theme plugin.

    I can’t find the option to disable WooCommerce recommending other items on the side of the page.

    See this screenshot for an example.

    Can anyone help me remove this option? Thanks

    Removed this by going to my wp-content/themes/jupiter/framework/functions/general-functions.php and adding this link to the end to remove the $output content.

    $output = ”; //added to remove the prev/next post navigation

    /**
    * Adds Next/Previous post navigations to single posts
    *
    */

    function mk_post_nav($same_category = true, $taxonomy = ‘category’)
    {

    global $mk_options;

    if(is_singular(‘portfolio’) && $mk_options[‘portfolio_next_prev’] != ‘true’) return false;

    if(is_singular(‘post’) && $mk_options[‘blog_prev_next’] != ‘true’) return false;

    $options = array();
    $options[‘same_category’] = $same_category;
    $options[‘excluded_terms’] = ”;

    $options[‘type’] = get_post_type();
    $options[‘taxonomy’] = $taxonomy;

    if(!is_singular() || is_post_type_hierarchical($options[‘type’]))
    $options[‘is_hierarchical’] = true;
    if($options[‘type’] === ‘topic’ || $options[‘type’] === ‘reply’)
    $options[‘is_bbpress’] = true;

    $options = apply_filters(‘mk_post_nav_settings’, $options);
    if(!empty($options[‘is_bbpress’]) || !empty($options[‘is_hierarchical’]))
    return;

    $entries[‘prev’] = get_previous_post($options[‘same_category’], $options[‘excluded_terms’], $options[‘taxonomy’]);
    $entries[‘next’] = get_next_post($options[‘same_category’], $options[‘excluded_terms’], $options[‘taxonomy’]);

    $entries = apply_filters(‘mk_post_nav_entries’, $entries, $options);
    $output = “”;

    foreach ($entries as $key => $entry)
    {
    if(empty($entry)) continue;

    $post_type = get_post_type($entry->ID);

    $icon = $post_image = “”;
    $link = get_permalink($entry->ID);
    $image = get_the_post_thumbnail($entry->ID, ‘thumbnail’);
    $class = $image ? “with-image” : “without-image”;
    $icon = ($key == ‘prev’) ? ‘‘ : ‘‘;
    $output .= ‘‘;

    $output .= ‘‘;
    $output .= ‘‘;

    $icon = ‘‘.$icon.’‘;

    if($image) {
    $post_image = ‘‘.$image.’‘;
    }

    $output .= $key == ‘next’ ? $icon.$post_image : $post_image.$icon;
    $output .= “”;

    $output .= ‘

    $output .= ‘‘.get_the_title($entry->ID).’‘;

    if($post_type == ‘post’) {
    //$output .= ‘‘.get_the_category_list( ‘, ‘, ‘single’, $entry->ID ).’‘;

    } elseif ($post_type == ‘portfolio’) {
    $terms = get_the_terms($entry->ID, ‘portfolio_category’);
    $terms_slug = array();
    $terms_name = array();
    if (is_array($terms)) {
    foreach($terms as $term) {
    $terms_name[] = $term->name;
    }
    }
    $output .= ‘‘.implode(‘, ‘, $terms_name).’‘;
    } elseif ($post_type == ‘product’) {
    $terms = get_the_terms($entry->ID, ‘product_cat’);
    $terms_slug = array();
    $terms_name = array();
    if (is_array($terms)) {
    foreach($terms as $term) {
    $terms_name[] = $term->name;
    }
    }
    $output .= ‘‘.implode(‘, ‘, $terms_name).’‘;
    } elseif($post_type == ‘news’){
    $terms = get_the_terms($entry->ID, ‘news_category’);
    $terms_slug = array();
    $terms_name = array();
    if (is_array($terms)) {
    foreach($terms as $term) {
    $terms_name[] = $term->name;
    }
    }
    $output .= ‘‘.implode(‘, ‘, $terms_name).’‘;
    }
    $output .= “”;
    $output .= ”

    “;
    $output .= “”;
    $output .= “”;
    }
    echo $output;
    }
    add_action( ‘wp_footer’, ‘mk_post_nav’ );

    function mk_get_fontfamily( $element_name, $id, $font_family, $font_type ) {
    $output = ”;
    if ( $font_type == ‘google’ ) {
    if ( !function_exists( “my_strstr” ) ) {
    function my_strstr( $haystack, $needle, $before_needle = false ) {
    if ( !$before_needle ) return strstr( $haystack, $needle );
    else return substr( $haystack, 0, strpos( $haystack, $needle ) );
    }
    }
    wp_enqueue_style( $font_family, ‘//fonts.googleapis.com/css?family=’ .$font_family.’:300italic,400italic,600italic,700italic,800italic,400,300,800,700,600′ , false, false, ‘all’ );
    $format_name = strpos( $font_family, ‘:’ );
    if ( $format_name !== false ) {
    $google_font = my_strstr( str_replace( ‘+’, ‘ ‘, $font_family ), ‘:’, true );
    } else {
    $google_font = str_replace( ‘+’, ‘ ‘, $font_family );
    }
    $output .= ‘

    ‘;

    } else if ( $font_type == ‘fontface’ ) {

    $stylesheet = FONTFACE_DIR.’/fontface_stylesheet.css’;
    $font_dir = FONTFACE_URI;
    if ( file_exists( $stylesheet ) ) {
    $file_content = file_get_contents( $stylesheet );
    if ( preg_match( “/@font-face\s*{[^}]*?font-family\s*:\s*(‘|\”)$font_family\\1.*?}/is”, $file_content, $match ) ) {
    $fontface_style = preg_replace( “/url\s*\(\s*[‘|\”]\s*/is”, “\$font_dir/”, $match[0] ).”\n”;
    }
    $output = “\n

    ‘;
    }

    } else if ( $font_type == ‘safefont’ ) {
    $output .= ‘

    ‘;
    }

    return $output;
    }

  • WordPress plugins: downloading old versions

    Go to the plugin page hosted at wordpress.org

    https://wordpress.org/plugins

    Click on the Developer tab and you’ll find the list of previous releases.