Forum Replies Created

Viewing 15 replies - 46 through 60 (of 120 total)
  • Plugin Contributor netzgestaltung

    (@netzgestaltung)

    I see, i was missing some necessary data:

    * Contact Form 7 5.2
    * Really Simple CAPTCHA 2.0.2
    * CF7 Smart Grid Design Extension 3.3.2

    When i deactivate CF7 Smart Grid Design Extension the Capchta starts working (but the Metaboxes for Polylang are gone).

    I established a languages workaround in the templates that call forms so for now the frontend works without CF7 Smart Grid Design Extension

    Thread Starter netzgestaltung

    (@netzgestaltung)

    When i search for “encoder” in the wp-plugins directory i get 2 pages of results.

    Maybe a whitelisting for the specific plugin names would be an option (on AIOWPS side).

    https://www.ads-software.com/plugins/search/encoder/

    Thread Starter netzgestaltung

    (@netzgestaltung)

    thanks for that!

    maybe if you ask on their support forum, they have other ideas what to do (also for other plugin authors)

    kind regards
    tom

    Thread Starter netzgestaltung

    (@netzgestaltung)

    I am not sure.

    The only malformed files where wp-config and a few plugin files.
    Also static folders with pictures from an old instance of drupal where affected with index.php files.

    wp-core files stayed untouched, the where the usual files with “Pharma Hack” signature “/php \$[a-zA-Z]*=\’as\’;/”

    the modified plugin files looked more randomly used so i think it should not be related to it.

    wp-content/plugins/just-custom-fields/models/Shortcodes.php
    wp-content/plugins/just-custom-fields/controllers/PostTypeController.php
    wp-content/plugins/crop-thumbnails/crop-thumbnails.php
    wp-content/plugins/stops-core-theme-and-plugin-updates/includes/MPSUM_Check_Plugin_Install_Status.php

    at least there where some hidden files tarned as “*.ico” but with the same pattern as for the PHP files and with similar content.

    Hi, i just kept my old script and within the old links to solve that problem:

    DISCLAIMER: Please handle with care and test. I am not responsible for errors that might come up with that:
    https://github.com/netzgestaltung/wordpress-snippets/blob/master/old_jcf_settings.php

    kind regards, tom

    Thread Starter netzgestaltung

    (@netzgestaltung)

    The problem was that when using get_comment_text the usual comment_text filter was not used at all and some filters where missing:

    
    add_filter( 'comment_text', 'wptexturize'            );
    add_filter( 'comment_text', 'convert_chars'          );
    add_filter( 'comment_text', 'make_clickable',      9 );
    add_filter( 'comment_text', 'force_balance_tags', 25 ); 
    add_filter( 'comment_text', 'convert_smilies',    20 );
    add_filter( 'comment_text', 'wpautop',            30 );
    

    Reference: https://stackoverflow.com/a/2609197/1165121

    also using comment_text() did not work because its then filtered infinite.
    removing the rating filter temporary did also not work in my themes funcion.

    This is what now works for me:

    i combined all values regarding to rating in an array an use it as parameter for the filter apply_filters('wpcr_comment_tut_add_title_to_text', $comment_text, $rating, $comment).

    /wp-post-comment-rating/inc/function.php line 136

    
    ///// show rating stars with visitors comment /////
    add_filter('comment_text','wpcr_comment_tut_add_title_to_text',99,2);
    function wpcr_comment_tut_add_title_to_text($comment_text, $comment){
      $wpcr_options = get_option('wpcr_settings'); // no need for $wpdb
      $rating = array( // all rating values combined for better filtering afterwards
        'enable' => apply_filters('wpcr_options_checkbox1', $wpcr_options['checkbox1'], $comment), // "Enable rating" possible overwrite on per post_type basis
        'text' => '', // added to $comment_text
        'star_pos' => 'above', // default stars position
        'filtered_comment_content' => $comment_text, // Was allready filtered
      );
    
      if ( $rating['enable'] ) { // "Enable rating"
        $rating['rating'] = get_comment_meta($comment->comment_ID, 'rating', true);
    
        if ( $rating['rating'] ) {
          $rating_inner_text = '(' . $rating['rating'] . '/5)';
          $rating['text'] = '<div class="cmstr-out"><span class="wpcr_author_stars" data-rating="' . $rating['rating'] . '" ></span></div><span class="tval">' . $rating_inner_text . '</span>';
    
          if ( isset($wpcr_options['cmstr_pos']) && $wpcr_options['cmstr_pos'] === 0 ) {
            $rating['star_pos'] = 'below';
          }
    
          if ( $rating['star_pos'] === 'above' ) {
            $comment_text = $rating['text'] . $rating['filtered_comment_content'];
          } else {
            $comment_text = $rating['filtered_comment_content'] . $rating['text'];
          }
        }
      }
      return apply_filters('wpcr_comment_tut_add_title_to_text', $comment_text, $rating, $comment);
    }
    

    This is now how my theme works (with getting all the rating values, its much smaller):

    
    add_filter('wpcr_comment_tut_add_title_to_text', 'myTheme_comment_rating_comment_text', 10, 3);
    
    function sandbox_comment_rating_comment_text($comment_text, $rating, $comment){
      $profile_post_ID = 1234; // on profile page or descendants
      $star_pos = isset($rating['star_pos']) ? $rating['star_pos'] : 'above'; // default stars position
      $enable_rating = isset($rating['enable']) ? $rating['enable'] : false;
    
      if ( $enable_rating ) { // "Enable rating"
        if ( isset($rating['rating']) ) {
          $post = get_post();
          $parents = get_post_ancestors($post);
          $parents[] = $post->ID;
    
          if ( in_array($profile_post_ID, $parents) ) {
            $star_pos = 'above';
          }
    
          if ( $star_pos === 'above' ) {
            $comment_text = $rating['text'] . $rating['filtered_comment_content'];
          } else {
            $comment_text = $rating['filtered_comment_content'] . $rating['text'];
          }
        }
      }
      return $comment_text;
    }
    
    Thread Starter netzgestaltung

    (@netzgestaltung)

    Hi there,

    i think i need to test the code a bit more to get it working in all circumstances.

    i’ll update you here with a new post then.

    Thread Starter netzgestaltung

    (@netzgestaltung)

    hi there,

    the previous one was the filter with my template logic – its different on the profile page.

    this is the function.php full code for function “wpcr_comment_tut_add_title_to_text” i would suggest:

    
    function wpcr_comment_tut_add_title_to_text($text, $comment){
      $wpcr_options = get_option('wpcr_settings'); // no need for $wpdb
      $enable_rating = apply_filters('wpcr_options_checkbox1', $wpcr_options['checkbox1'], $comment); // "Enable rating" possible overwrite on per post_type basis
      $rating_text = ''; // added to $comment_text
      $star_pos = 'above'; // default stars position
    
      if ( $enable_rating ) { // "Enable rating"
        $rating = get_comment_meta($comment->comment_ID, 'rating', true);
    
        if ( $rating ) {
          $post = get_post();
          $parents = get_post_ancestors($post);
          $parents[] = $post->ID;
          $rating_inner_text = '(' . $rating . '/5)';
          $rating_text = '<div class="cmstr-out"><span class="wpcr_author_stars" data-rating="' . $rating . '" ></span></div><span class="tval">' . $rating_inner_text . '</span>';
          $comment_text = get_comment_text($comment);
    
          if ( isset($wpcr_options['cmstr_pos']) && $wpcr_options['cmstr_pos'] === 0 ) {
            $star_pos = 'below';
          }
    
          if ( $star_pos === 'above' ) {
            $text = $rating_text . $comment_text;
          } else {
            $text = $comment_text . $rating_text;
          }
        }
      }
      return apply_filters('wpcr_comment_tut_add_title_to_text', $text, $comment);
    }
    

    if you had a github repository i would send you pull requests

    Thread Starter netzgestaltung

    (@netzgestaltung)

    Here is the result of my themes function, changing the $star_pos depending on a page id or on the setting

    
    function myTheme_comment_rating_comment_text($text, $comment){
      $profile_post_ID = 1234; // on profile page or descendants
      $wpcr_options = get_option('wpcr_settings'); // no need for $wpdb
      $enable_rating = apply_filters('wpcr_options_checkbox1', $wpcr_options['checkbox1'], $comment); // "Enable rating" possible overwrite on per post_type basis
      $rating_text = ''; // added to $comment_text
      $star_pos = 'above'; // default stars position 
    
      if ( $enable_rating ) {
        $rating = get_comment_meta($comment->comment_ID, 'rating', true);
    
        if ( $rating ) {
          $post = get_post();
          $parents = get_post_ancestors($post);
          $parents[] = $post->ID;
          $rating_inner_text = '(' . $rating . '/5)';
          $rating_text = '<div class="cmstr-out"><span class="wpcr_author_stars" data-rating="' . $rating . '" ></span></div><span class="tval">' . $rating_inner_text . '</span>';
          $comment_text = get_comment_text($comment);
    
          if ( !in_array($profile_post_ID, $parents) && isset($wpcr_options['cmstr_pos']) && $wpcr_options['cmstr_pos'] === 0 ) {
            $star_pos = 'below';
          }
    
          if ( $star_pos === 'above' ) {
            $text = $rating_text . $comment_text;
          } else {
            $text = $comment_text . $rating_text;
          }
        }
      }
      return $text;
      // return apply_filters('myTheme_comment_rating_comment_text', $text, $comment);
    }
    

    kind regards
    tom

    Thread Starter netzgestaltung

    (@netzgestaltung)

    hi there,

    finally i got the first ratings to show:
    https://www.alphabetisierung.at/lernmaterial/

    kind regards, tom

    Thread Starter netzgestaltung

    (@netzgestaltung)

    Oh

    it started working “surprisingly” after configuring the plugin.

    ??

    Thread Starter netzgestaltung

    (@netzgestaltung)

    i now got my personal template code ready and integrated a “no text” version and the shortcode title

    you can grab it here:
    https://github.com/netzgestaltung/wordpress-snippets/blob/master/wp-post-rating_order-posts.php

    here is also some CSS i had to add to my template while the stars occur on different places on the page i am working on. The “article” selector is only there to overwrite the plugin CSS rules.

    article .wpcr_aggregate{
      float:none;
      width:auto;
      display:block;
      line-height:2em;
      min-height:2em;
      margin:0 0 1em 0;
    }
    article .title .wpcr_aggregate{
      display:inline;
      line-height:inherit;
    }
    article span.wpcr_averageStars{
      display:inline-block;
    }
    article .wpcr_tooltip,
    article .wpcr_inline,
    article a.wpcr_tooltip span.wpcr_averageStars,
    article a.wpcr_inline span.wpcr_averageStars{
      float:none;
    }
    .content a.wpcr_tooltip span.wpcr_averageStars, 
    .content a.wpcr_inline span.wpcr_averageStars{
      margin:0.238095238em 0.5em 0 0.5em;
    }

    maybe i can share the live url next week.

    top! exactly what i need right now, thanks.

    Thread Starter netzgestaltung

    (@netzgestaltung)

    i now added 2 functions + 1 action within

    the hooked function at ‘save_post’ now saves the zero value of ‘_wpcr_rating’ to every post that gets saved.

    it was neccesarry because WP_Query also filters posts when using orderby on meta_key/meta_value/meta_query arguments and sorting was not possible when having two clauses with EXISTS and NOT EXISTS compare operators

    
    // sets post_meta '_wpcr_rating' to zero when not having comments
    function myPlugin_save_post($post_id, $post, $update){
      if ( !$post->_wpcr_rating ) {
        update_post_meta($post_id, '_wpcr_rating', 0);
      }
    }
    add_action( 'save_post', 'myPlugin_save_post', 10, 3);

    for an initial handling i added a function that saves the zero value once to all posts that does not have it.

    
    // sets all existing posts '_wpcr_rating' meta field to zero, 
    // customize the query args, only use once
    function myPlugin_set_rating(){
      $args = array(
        'post_type' => 'my_post_type',
        'posts_per_page' => -1,
        'meta_query' => array(
          'rating_all' => array(
            'key' => '_wpcr_rating',
            'compare' => 'NOT EXISTS',
          ),
        ),
      );
      $query = new WP_Query($args);
      if ( $query->have_posts() ) {
        while ( $query->have_posts() ) {
          $query->the_post();
          update_post_meta(get_the_ID(), '_wpcr_rating', 0);
        }
        wp_reset_postdata();
      }
    }

    putted it together here: https://github.com/netzgestaltung/wordpress-snippets/blob/master/wp-post-rating_order-posts.php

    Thread Starter netzgestaltung

    (@netzgestaltung)

    i added the code to my snippets repository here:
    https://github.com/netzgestaltung/wordpress-snippets/blob/master/wp-post-rating_order-posts.php

    i added documentation to it

    i dont know if i will have time until friday to check the other orderby suggestions

Viewing 15 replies - 46 through 60 (of 120 total)