Forum Replies Created

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter Sandra

    (@foodcat)

    I think you didn’t understand my problem that is why i uploaded a picture:
    https://picload.org/view/daapgpll/parallaxbug.png.html

    I isn’t clipping and adapting the right way anymore like it did in 2.0.2, like i say i had to roll back to 2.0.2 because i can’t present that bug to my users, it is the first thing they see in the end

    @ctrlaltdelete thanks i fixed it ??

    you can add an background with base64 in css of that png image, so its loaded over css only one time, so you need 3 classes full star, half star and empty star.
    and than a div that uses this class instead of an image

    I finished my fontawesome version.
    Feel free to test and use it.

    https://foodcat.de/wp-postratings-with-fontawesome.rar

    How to install:

    1. Make sure your WordPress has a fontawesome library activated
    2. open your functions.php and add:

    add_filter( 'wp_postratings_image_extension', 'custom_rating_image_extension' );
    function custom_rating_image_extension() {
        return 'fontawesome';
    }

    3. have fun

    PS: sorry that svg inline is cool but in the end I use fontawesome anyway and this is what i could do easily
    feel free to chance it to a better svg one

    PS: I have it live on my page if you want to see the stars working
    https://www.foodcat.de/rezepte/mozzarella-hackbaellchen-mit-gemuese-bento/

    In end, i hope it looks like my fontawesome prototype if folked here:
    https://codepen.io/anon/pen/gvjEMP

    I feel that is so much easier to do (maybe because I’m not used to it)

    somehow it doesn’t like me.

    i added these svgs to the DOM

    <svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink">
                        <defs>
                        <symbol
                        id="postrating-star" viewBox="0 0 24 28">
                        <path d="M1728 647q0 22-26 48l-363 354 86 500q1 7 1 20 0 21-10.5 35.5t-30.5 14.5q-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z"/>
                        </symbol>
                        </defs>
            </svg>
            <svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink">
                        <defs>
                        <symbol
                        id="postrating-star-half" viewBox="0 0 24 28">
                        <path d="M1250 957l257-250-356-52-66-10-30-60-159-322v963l59 31 318 168-60-355-12-66zm452-262l-363 354 86 500q5 33-6 51.5t-34 18.5q-17 0-40-12l-449-236-449 236q-23 12-40 12-23 0-34-18.5t-6-51.5l86-500-364-354q-32-32-23-59.5t54-34.5l502-73 225-455q20-41 49-41 28 0 49 41l225 455 502 73q45 7 54 34.5t-24 59.5z"/>
                        </symbol>
                        </defs>
            </svg>
            <svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink">
                        <defs>
                        <symbol
                        id="postrating-star-off" viewBox="0 0 24 28">
                        <path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z"/>
                        </symbol>
                        </defs>
            </svg>

    but non of them work as wished,
    can you fix that for me, then i can finish the function.

    You can get the refactored file here:
    https://www.foodcat.de/postratings.rar

    I made a simple test if(true) at a already voted page view so i can check out the svg there, but it won’t work

    ah so it is not loading every svg with a single call.

    Do you have a documentation how to send svgs to the footer?
    Then i totally agree with you, that this is a way better solution

    but i didn’t start implementing anything with fontawesome yet because i first refactored that function, there may be even better solutions, but i don’t like the same code over and over again, so i fixed it for a better reading for myself:

    $ratings_image = esc_attr( $ratings_image );
        if(is_rtl() && file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_start-rtl.'.RATINGS_IMG_EXT)) {
            $ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_start-rtl.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
        } elseif(file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_start.'.RATINGS_IMG_EXT)) {
            $ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_start.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
        }
        if($ratings_custom) {
            for($i=1; $i <= $ratings_max; $i++) {
                if (is_rtl() && file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_'.$i.'half-rtl.'.RATINGS_IMG_EXT)) {
                    $use_half_rtl = 1;
                } else {
                    $use_half_rtl = 0;
                }
                $ratings_text = esc_attr( stripslashes( $ratings_texts[$i-1] ) );
                $ratings_text_js = esc_js( $ratings_text );
                $image_alt = apply_filters( 'wp_postratings_ratings_image_alt', $ratings_text );
                if($i <= $post_rating) {
                    $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_'.$i.'_on.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                } elseif($i == $insert_half) {
                    if ($use_half_rtl) {
                        $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_'.$i.'_half-rtl.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                    } else {
                        $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_'.$i.'_half.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                    }
                } else {
                    $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_'.$i.'_off.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                }
            }
        } else {
            if (is_rtl() && file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_half-rtl.'.RATINGS_IMG_EXT)) {
                $use_half_rtl = 1;
            } else {
                $use_half_rtl = 0;
            }
            for($i=1; $i <= $ratings_max; $i++) {
                $ratings_text = esc_attr( stripslashes( $ratings_texts[$i-1] ) );
                $ratings_text_js = esc_js( $ratings_text );
                $image_alt = apply_filters( 'wp_postratings_ratings_image_alt', $ratings_text );
                if($i <= $post_rating) {
                    $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_on.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                } elseif($i == $insert_half) {
                    if ($use_half_rtl) {
                        $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_half-rtl.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                    } else {
                        $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_half.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                    }
                } else {
                    $ratings_images .= '<img id="rating_'.$post_id.'_'.$i.'" src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_off.'.RATINGS_IMG_EXT).'" alt="'.$image_alt.'" title="'.$image_alt.'" onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" />';
                }
            }
        }
        if(is_rtl() && file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_end-rtl.'.RATINGS_IMG_EXT)) {
            $ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_end-rtl.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
        } elseif(file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_end.'.RATINGS_IMG_EXT)) {
            $ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_end.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
        }

    after

    $ratings_image = esc_attr( $ratings_image );
    		if(is_rtl() && file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_start-rtl.'.RATINGS_IMG_EXT)) {
    			$ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_start-rtl.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
    		} elseif(file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_start.'.RATINGS_IMG_EXT)) {
    			$ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_start.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
    		}
    
    			for($i=1; $i <= $ratings_max; $i++) {
    				
    				if (is_rtl() 
    					&& (file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_'.$i.'_half-rtl.'.RATINGS_IMG_EXT) 
    						|| file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_half-rtl.'.RATINGS_IMG_EXT))) {
    					$use_half_rtl = 1;
    				} else {
    					$use_half_rtl = 0;
    				}
    				$ratings_text = esc_attr( stripslashes( $ratings_texts[$i-1] ) );
    				$ratings_text_js = esc_js( $ratings_text );
    				$image_alt = apply_filters( 'wp_postratings_ratings_image_alt', $ratings_text );
    				
    				// which img should be displayed
    				if($i <= $post_rating) {
    					$imgtype = "on";
    				} elseif($i == $insert_half) {
    					if ($use_half_rtl) {
    						$imgtype = "half-rtl";
    					} else {
    						$imgtype = "half";
    					}
    				} else {
    					$imgtype = "off";
    				}
    				//different image for every position
    				if($ratings_custom) {
    					$customfiller = $i.'_';
    				}
    				$ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_'.$customfiller.$imgtype.'.'.RATINGS_IMG_EXT).'" 
    										id="rating_'.$post_id.'_'.$i.'"
    										alt="'.$image_alt.'" title="'.$image_alt.'" 
    										onmouseover="current_rating('.$post_id.', '.$i.', \''.$ratings_text_js.'\');" 
    										onmouseout="ratings_off('.$post_rating.', '.$insert_half.', '.$use_half_rtl.');" 
    										onclick="rate_post();" onkeypress="rate_post();" 
    										style="cursor: pointer; border: 0px;" />';
    				
    			}
    		if(is_rtl() && file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_end-rtl.'.RATINGS_IMG_EXT)) {
    			$ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_end-rtl.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
    		} elseif(file_exists(WP_PLUGIN_DIR.'/wp-postratings/images/'.$ratings_image.'/rating_end.'.RATINGS_IMG_EXT)) {
    			$ratings_images .= '<img src="'.plugins_url('/wp-postratings/images/'.$ratings_image.'/rating_end.'.RATINGS_IMG_EXT).'" alt="" class="post-ratings-image" />';
    		}

    but there are two more functions that need to be optimized

    I forgot to say, i optimized my fontawesome file with:
    https://fontforge.github.io/
    https://transfonter.org/

    Then you can realy choose the items you need without losing its flexibility

    Like it said, it is only for people that already included fontawesome in their page ??

    SVG still is the better option but still you will have more requests if you are using more icons than only that star

    PS: svg should working already, so why are you so mad

    install a plugin like “SVG Support”

    add_filter( 'wp_postratings_image_extension', 'custom_rating_image_extension' );
    function custom_rating_image_extension() {
        return 'svg';
    }

    and a folder with your svgs to the postrating plugin (like any other costum image)

    But you are right with the overblow, but you can optimize your iconfont to your needs with tools like:
    https://fontello.com/

    • This reply was modified 6 years, 9 months ago by Sandra.
    • This reply was modified 6 years, 9 months ago by Sandra.

    Hi,

    I like the idea of using fontawesome instead of images.

    But this solution does seem right to me. Why?
    Why do you use font icons?
    1. You want them responsive, scalable and fillable (you got that in your code yes)
    2. You want to reduce server requests by exchanging images for font icons (i don’t see that here)

    So the feature you realy need is a switch that turns of the img tag generation and adds italic tags with font awesome classes to it.
    So everyone who has loaded fontawesome simply activate the feature or simpler for the start something like this:

    add_filter( 'wp_postratings_image_extension', 'custom_rating_image_extension' );
    function custom_rating_image_extension() {
        return 'fontawesome';
    }

    I think I try making a version for that and on my way fixing the problem of adding click handlers to most popular post widget .I did a quick and dirty solution on my page just deleting the event handlers via jquery:
    https://www.foodcat.de/blog
    But it would be better if they don’t get generated at all there.

    @gamerz If you like it you can merge it into your trunk

    Hi,
    these are temporary configurations.

    you can see them with this plugin:
    https://de.www.ads-software.com/plugins/transients-manager/

    the cooked plugin that is in conflict with your has an entry there about queries

    @twinpictures
    sorry it’s me again. somehow the error came again and it has to do with overtime transient options. They were cleared and then the error came back

    Works nice on my system, thank you again. ??

    I hope Shaun Robinson’s problem is also solved.

    Thanks that version works ??

    Hi,

    I had the same problem. It was caused by another plugin causing conflicts, check your stacktrace maybe you will see some other plugin causing this error too.
    In my case it was the Anual Archive widget:

    08.02.2018 09:16:09 servername [client  ] PHP Fatal error:  Uncaught Error: Call to a member function get() on null in wp-includes/query.php:28
    08.02.2018 09:16:09 servername [client  ] Stack trace:
    08.02.2018 09:16:09 servername [client  ] #0 wp-content/plugins/anual-archive/annual_archive.php(771): get_query_var('decade')
    08.02.2018 09:16:09 servername [client  ] #1 wp-includes/class-wp-hook.php(286): annual_archive_decade_filter(Object(WP_Query))
    08.02.2018 09:16:09 servername [client  ] #2 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    08.02.2018 09:16:09 servername [client  ] #3 wp-includes/plugin.php(515): WP_Hook->do_action(Array)
    08.02.2018 09:16:09 servername [client  ] #4 wp-includes/class-wp-query.php(1634): do_action_ref_array('pre_get_posts', Array)
    08.02.2018 09:16:09 servername [client  ] #5 wp-includes/class-wp-query.php(3222): WP_Query->get_posts()
    08.02.2018 09:16:09 servername [client  ] #6 wp-includes/class-wp-query.php(3328): WP_Query->query(Array)
    08.02.2018 09:16:09 servername [client  ] #7 wp-content/plugins/cooked/includes/class.cooked-recipes.php(100): WP_Query->_ in wp-includes/query.php on line 28

    Maybe Boxy Studio can build in a try catch function to be save against bad plugins ??

    I have the same problem,
    it creates a conflict with the plugin cooked, maybe you can use it to find the reason

    08.02.2018 09:16:09 servername [client  ] PHP Fatal error:  Uncaught Error: Call to a member function get() on null in wp-includes/query.php:28
    08.02.2018 09:16:09 servername [client  ] Stack trace:
    08.02.2018 09:16:09 servername [client  ] #0 wp-content/plugins/anual-archive/annual_archive.php(771): get_query_var('decade')
    08.02.2018 09:16:09 servername [client  ] #1 wp-includes/class-wp-hook.php(286): annual_archive_decade_filter(Object(WP_Query))
    08.02.2018 09:16:09 servername [client  ] #2 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    08.02.2018 09:16:09 servername [client  ] #3 wp-includes/plugin.php(515): WP_Hook->do_action(Array)
    08.02.2018 09:16:09 servername [client  ] #4 wp-includes/class-wp-query.php(1634): do_action_ref_array('pre_get_posts', Array)
    08.02.2018 09:16:09 servername [client  ] #5 wp-includes/class-wp-query.php(3222): WP_Query->get_posts()
    08.02.2018 09:16:09 servername [client  ] #6 wp-includes/class-wp-query.php(3328): WP_Query->query(Array)
    08.02.2018 09:16:09 servername [client  ] #7 wp-content/plugins/cooked/includes/class.cooked-recipes.php(100): WP_Query->_ in wp-includes/query.php on line 28

    PS: my WP version is 4.9.4

    • This reply was modified 6 years, 9 months ago by Sandra. Reason: WP Version
Viewing 15 replies - 1 through 15 (of 21 total)