Forum Replies Created

Viewing 9 replies - 121 through 129 (of 129 total)
  • Plugin Author yoav.aner

    (@yoavaner)

    This is probably not the right forum, since I’m trying to solve a bug in another plugin, but I’ve had a quick look and if you want a real quick-n-dirty fix for ajax-the-views (not for my plugin though), then try adding this javascript to your footer.php (right after wp_footer)

    like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Plugin Author yoav.aner

    (@yoavaner)

    Plugin Author yoav.aner

    (@yoavaner)

    Hi evo252,

    I’m not entirely sure to be honest. Had a quick-check and got the same behaviour as you. I’m not familiar with this particular plugin, but it might check the views based on information in the page/post itself, and therefore, when accessed via the ajax call, it doesn’t get the contextual information it needs…

    Don’t think there’s much I can do about that, but best thing is to contact the plugin author.

    I did however notice on the plugin info that it claims to work with caching solutions.

    Yoav

    I think that cloudfront filters the parameters from dynamic scripts, so it doesn’t actually pass the ?src=… parameters to your server to fetch the image and cache it.

    I managed to find a solution to this by using .htaccess rewrite rules to effectively change the url so it gets processed by cloudfront.

    You can read about it on http://blog.gingerlime.com/thumbs-up

    …and a wordpress stack exchange question (http://wordpress.stackexchange.com/questions/9076/why-is-my-database-import-losing-text-widget-data) led me to the solution (which I also posted there):

    To migrate your wordpress and to a new url / domain name, do the following:

    1. Take a DB dump (e.g. using phpmyadmin) of the existing wordpress
    2. Restore the dump as-is, (without modifications!) to your new location
    3. Unzip the script from http://spectacu.la/search-and-replace-for-wordpress-databases/ into your wordpress home folder (it’s not a plugin…)
    4. Run the script on your new site by pointing your browser to it, e.g. http://new-website.url/searchreplacedb.php
    5. Don’t forget to delete the script from your new wordpress home

    I also noticed there’s another open post with the same problem http://wordpress.org/support/topic/wordpress-migration-widgets-are-not-transferred

    I’m having exactly the same issue. I restored the wordpress db using phpmyadmin, but for some strange reason the text widgets are missing. Some other widgets are there on the sidebars, but not the text ones.

    Can you perhaps share your code to re-import those??

    Thread Starter yoav.aner

    (@yoavaner)

    Thanks Hugh,

    Yes, very similar, this is why I preferred to contribute to yours rather than to issue a separate plugin.

    Here’s the full modified code:

    <?php
    /*
        Plugin Name: WordPress Custom Post Type Archive
        Plugin URI: http://www.gingerlime.com
        Description: Displays a monthly or yearly archive of posts for one specific custom post type.
        Version: 1.0
        Requires at least: 3.1
        Author: Yoav Aner (based on WordPress Category Archive by Hugh Mandeville)
        License: GPL
    
        == Description ==
    
        The WordPress Custom Post Type Archive Widget Plugin displays a monthly or yearly archive of posts for one specific custom post type.
        It is very similar to the WordPress Archive except that it just displays one specific custom post type's posts.
        It can be configured to either show a listing or a pulldown of months or years with or without post counts.
    
        == Installation ==
    
        1. Upload "wp-custom-post-type-archive.php" to the "/wp-content/plugins/" directory.
        2. Activate the plugin through the "Plugins" menu in WordPress.
        3. From the "Widgets" page in WordPress drag the "Custom Post Type Archive" widget to the "Sidebar".
        4. Configure the "Custom Post Type Archive" widget controls, setting the "Title", "Custom Type", "Display Style", "Group By" and "Show Post Counts" fields.
    
    */
    
    class WP_CustomType_Archive_Widget extends WP_Widget
    {
        /**
         * Contstructor.  Set description and call parent class.
         */
        function WP_CustomType_Archive_Widget()
        {
            /* Widget settings. */
            $widget_ops = array("description" => "Display an archive listing of one specific custom-type.");
    
            /* Create the widget. */
            $this->WP_Widget("wp-customtype-archive", "Custom Type Archive", $widget_ops);
        }
    
        /**
         * Creates URL for archive links to the yearly or monthly custom type listing.
         * The URL has the year, month and custom post type in the query string
         *      ?m=201001&post_type=2
         */
        function create_url($interval, $year, $month, $customtype)
        {
            global $wp_rewrite;
            $year_month_value = $year . $month;
            $year_month_path = $year . "/" . $month;
            if ($interval == "year") {
                $year_month_value = $year;
                $year_month_path = $year . "/00";
            }
    
            $url = get_option('home') . "/?m=" . $year_month_value . "&post_type=" . $customtype; 
    
    /*	if ($wp_rewrite->using_permalinks()) {
                $cat_pos = strpos($wp_rewrite->permalink_structure, "%" . $customtype . "%");
                if ($cat_pos != false) {
                    // if %category% is in the permalink structure, figure out if year is before or after it
                    $year_pos = strpos($wp_rewrite->permalink_structure, "%year%");
                    if ($year_pos != false) {
                        $url = get_option('home') . "/";
                        if ($cat_pos < $year_pos) {
                            $url .= $customtype . "/" . $year_month_path . "/";
                        } else {
                            $url .=  $year_month_path . "/" . $customtype . "/";
                        }
                    }
                }
            }
    */
            return ($url);
        }
    
        /**
         * Display widget.
         */
        function widget($args, $instance)
        {
            extract($args);
    
            /* User-selected settings. */
            //$title = apply_filters('widget_title', $instance['title'] );
            $title = esc_attr($instance['title']);
    	$customtype = esc_attr($instance['customtype']);
            $display_style = $instance['display_style'];
            $interval = $instance['interval'];
            $show_counts = intval($instance['show_counts']);
            echo $before_widget;
            /* Title of widget (before and after defined by themes). */
            if ( $title ) {
                echo $before_title . $title . $after_title;
            }
    
            // TBD: could change to call sql statement that uses group by
            $myposts = get_posts("numberposts=-1&offset=0&post_type=" . $customtype . "&orderby=date&order=DESC");
            $previous_year_month_display = "";
            $previous_year_month_value = "";
            $previous_year = "";
            $previous_month = "";
            $count = 0;
    
            $display_format = "F Y";
            $compare_format = "Ym";
            $select_str = __("Select Month");
            if ($interval == "year") {
                $display_format = "Y";
                $compare_format = "Y";
                $select_str = __("Select Year");
            }
    
            if ($display_style == "pulldown") {
                echo "<select name=\"wp-customtype-archive-dropdown\" onchange=\"document.location.href=this.options[this.selectedIndex].value;\">";
                echo " <option value=\"\">" . $select_str . "</option>";
            } else if ($display_style == "list") {
                echo "<ul>";
            }
    
            foreach($myposts as $post) {
                $post_date = strtotime($post->post_date);
                $current_year_month_display = date_i18n($display_format, $post_date);
                $current_year_month_value = date($compare_format, $post_date);
                $current_year = date("Y", $post_date);
                $current_month = date("m", $post_date);
                if ($previous_year_month_value != $current_year_month_value) {
                    if ($count > 0) {
                        $url = $this->create_url($interval, $previous_year, $previous_month, $customtype);
                        if ($display_style == "pulldown") {
                            echo " <option value=\"" . $url . "\"";
                            if ($_GET['m'] == $previous_year_month_value) {
                                echo " selected=\"selected\" ";
                            }
                            echo ">" . $previous_year_month_display;
                            if ($show_counts == 1) {
                                echo  " (" . $count . ")";
                            }
                            echo "</option>";
                        } else if ($display_style == "list") {
                            echo "<li><a href=\"". $url . "\">" . $previous_year_month_display . "</a>";
                            if ($show_counts == 1) {
                                echo  " (" . $count . ")";
                            }
                            echo "</li>";
                        } else {
                            echo "<a href=\"". $url . "\">" . $previous_year_month_display . "</a>";
                            if ($show_counts == 1) {
                                echo  " (" . $count . ")";
                            }
                            echo "<br/>";
                        }
                    }
                    $count = 0;
                }
                $count++;
                $previous_year_month_display = $current_year_month_display;
                $previous_year_month_value = $current_year_month_value;
                $previous_year = $current_year;
                $previous_month = $current_month;
    
            }
            if ($count > 0) {
                $url = $this->create_url($interval, $previous_year, $previous_month, $customtype);
                if ($display_style == "pulldown") {
                    echo " <option value=\"" . $url . "\">" . $previous_year_month_display;
                    if ($show_counts == 1) {
                        echo " (" . $count . ")";
                    }
                    echo "</option>";
                } else if ($display_style == "list") {
                    echo "<li><a href=\"". $url . "\">" . $previous_year_month_display . "</a>";
                    if ($show_counts == 1) {
                        echo " (" . $count . ")";
                    }
                    echo "</li>";
                } else {
                    echo "<a href=\"". $url . "\">" . $previous_year_month_display . "</a>";
                    if ($show_counts == 1) {
                        echo " (" . $count . ")";
                    }
                    echo "<br/>";
                }
            }
            if ($display_style == "pulldown") {
                echo "</select>";
            } else if ($display_style == "list") {
                echo "</ul>";
            }
    
            echo $after_widget;
        }
    
        /**
         * Called when widget control form is posted.
         */
        function update( $new_instance, $old_instance )
        {
            // global $post;
            if (!isset($new_instance['submit'])) {
                return false;
            }
    
            $instance = $old_instance;
    
            /* Strip tags (if needed) and update the widget settings. */
            $instance["title"] = strip_tags($new_instance["title"]);
            $instance["customtype"] = strip_tags($new_instance["customtype"]);
            $instance["display_style"] = strip_tags($new_instance["display_style"]);
            $instance["interval"] = strip_tags($new_instance["interval"]);
            $instance["show_counts"] = intval($new_instance["show_counts"]);
            return $instance;
        }
    
        /**
         * Display widget control form.
         *  Title:
         *  Custom Type:
         *  Display Style:    Lines | (List) | Pulldown
         *  Group By:         (Month) | Year
         *  Show Post Counts: Yes | (No)
         */
        function form( $instance )
        {
            global $wpdb;
            /* Set up some default widget settings. */
            $defaults = array( "title" => "Archive", "customtype" => "", "display_style" => "list", "interval" => "month", "show_counts" => 1 );
            $instance = wp_parse_args( (array) $instance, $defaults );
            $title = esc_attr($instance['title']);
            $customtype = esc_attr($instance['customtype']);
            $display_style = $instance['display_style'];
            $interval = $instance['interval'];
            $show_counts = intval($instance['show_counts']);
    
            // Title
            echo "<p>";
            echo "<label for=\"" . $this->get_field_id("title") . "\">Title:";
            echo "<input id=\"" . $this->get_field_id("title") . "\" " .
                 "name=\"" . $this->get_field_name("title") . "\" " .
                 "value=\"" . $title . "\" style=\"width:100%;\" />";
            echo "<label></p>";
    
            // Custom Post Type (as string). TODO: add fancy dropdown option
            echo "<p>";
            echo "<label for=\"" . $this->get_field_id("customtype") . "\">Custom Type:";
            echo "<input id=\"" . $this->get_field_id("customtype") . "\" " .
                 "name=\"" . $this->get_field_name("customtype") . "\" " .
                 "value=\"" . $customtype . "\" style=\"width:100%;\" />";
            echo "<label></p>";
    
            // Display Style: Lines, List or Pulldown
            echo "<p>";
            echo "<label for=\"" . $this->get_field_id("display_style") . "\">Display Style:<br/>";
            echo "<input type=\"radio\" name=\"" . $this->get_field_name("display_style") . "\" value=\"lines\"";
            if ($display_style == "lines") {
                echo " checked=\"checked\" ";
            }
            echo "> Lines ";
            echo "<input type=\"radio\" name=\"" . $this->get_field_name("display_style") . "\" value=\"list\"";
            if ($display_style == "list") {
                echo " checked=\"checked\" ";
            }
            echo "> List ";
            echo "<input type=\"radio\" name=\"" . $this->get_field_name("display_style") . "\" value=\"pulldown\"";
            if ($display_style == "pulldown") {
                echo " checked=\"checked\" ";
            }
            echo "> Pulldown";
            echo "</label></p>";
    
            // Interval: Month or Year
            echo "<p>";
            echo "<label for=\"" . $this->get_field_id("interval") . "\">Group By:<br/>";
            echo "<input type=\"radio\" name=\"" . $this->get_field_name("interval") . "\" value=\"month\"";
            if ($interval != "year") {
                echo " checked=\"checked\" ";
            }
            echo "> Month ";
            echo "<input type=\"radio\" name=\"" . $this->get_field_name("interval") . "\" value=\"year\"";
            if ($interval == "year") {
                echo " checked=\"checked\" ";
            }
            echo "> Year";
            echo "</label></p>";
    
            // Show Counts: Yes or No
            echo "<p>";
            echo "<label for=\"" . $this->get_field_id("show_counts") . "\">Show Post Counts:<br/>";
            echo "<input type=\"radio\" name=\"" . $this->get_field_name("show_counts") . "\" value=\"1\"";
            if ($show_counts == 1) {
                echo " checked=\"checked\" ";
            }
            echo "> Yes ";
            echo "<input type=\"radio\" name=\"" . $this->get_field_name("show_counts") . "\" value=\"0\"";
            if ($show_counts != 0) {
                echo " checked=\"checked\" ";
            }
            echo "> No";
            echo "</label></p>";
    
            // Submit (hidden field)
            echo "<input type=\"hidden\" id=\"" . $this->get_field_id("submit") ."\" name=\"" .
                 $this->get_field_name("submit") . "\" value=\"1\" />";
        }
    
        /**
         * Register widget.
         */
        function register()
        {
            register_widget("WP_CustomType_Archive_Widget");
        }
    
    }
    
    // widgets_init hook, calls load widget function.
    add_action("widgets_init", array('WP_CustomType_Archive_Widget', 'register'));
    
    ?>

    Hi Ivan,

    I’m not sure if this is an old issue, but we don’t experience the same problem with our Pingdom plugin. I did notice the pingdomstatus.css being included on all pages, but nothing more than that. Even the css file is cached by the browser, and wordpress knows to return 304 response (to indicate the file hasn’t changed) so it’s not really a major issue as far as I can see…

    Yoav
    http://www.testuff.com

Viewing 9 replies - 121 through 129 (of 129 total)