Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • For anyone looking for a different solution for this, involves changing the recaptcha.php module for the plugin though but gives more flexibility I believe.

    There are two function in the module that need to be edited:

    function wpcf7_recaptcha_enqueue_scripts() {
      $service = WPCF7_RECAPTCHA::get_instance();
    
      if ( ! $service->is_active() ) {
        return;
      }
    
      $url = add_query_arg(
        array(
          // 'render' => $service->get_sitekey(),
          'render' => 'explicit' // Render the widget explicitly, needed if setting grecaptcha.render parameters
        ),
        'https://www.google.com/recaptcha/api.js'
      );
    
      wp_enqueue_script( 'google-recaptcha', $url, array(), '3.0', true );
    }

    and

    function wpcf7_recaptcha_onload_script() {
      $service = WPCF7_RECAPTCHA::get_instance();
    
      if ( ! $service->is_active() ) {
        return;
      }
    
      if ( ! wp_script_is( 'google-recaptcha', 'done' ) ) {
        return;
      }
    
    ?>
    <script type="text/javascript">
    ( function( grecaptcha, sitekey ) {
      var wpcf7recaptcha = {
        clientId: null,
    
        render: function() {
          this.clientId = grecaptcha.render(
            'google-recaptcha',
            {
              'badge' : 'bottomleft',
              'sitekey' : sitekey,
              'size' : 'invisible'
            }
          );
        },
    
        execute: function() {
          grecaptcha.execute(
            // sitekey,
            this.clientId, // use client ID returned by grecaptcha.render instead.
            { action: 'homepage' }
          ).then( function( token ) {
            var forms = document.getElementsByTagName( 'form' );
    
            for ( var i = 0; i < forms.length; i++ ) {
              var fields = forms[ i ].getElementsByTagName( 'input' );
    
              for ( var j = 0; j < fields.length; j++ ) {
                var field = fields[ j ];
    
                if ( 'g-recaptcha-response' === field.getAttribute( 'name' ) ) {
                  field.setAttribute( 'value', token );
                  break;
                }
              }
            }
          } );
        }
      };
    
      //grecaptcha.ready( wpcf7recaptcha.execute );
      grecaptcha.ready( function() {
        wpcf7recaptcha.render();
        wpcf7recaptcha.execute();
      } );
    
      document.addEventListener( 'wpcf7submit', wpcf7recaptcha.execute, false );
    
    } )( grecaptcha, '<?php echo esc_js( $service->get_sitekey() ); ?>' );
    </script>
    <?php
    }

    Had same problem and what fixed for me was to edit the line 438 from:

    $ord = unpack("N",$c)[1];

    to:

    $ord = unpack("N",$c);
    $ord = $ord[1];
    Forum: Plugins
    In reply to: Custom Post Type Parent

    i am having a similar problem with my CPT aswell,
    but my issue is that how do i separate the normal blog posts and CPT
    i have hunted the net for solutions but can not find any

    hi syrus69, to show only your custom posts create a page (i.e. page-artwork.php my case) and set your own WP_Query – have a code like this on the page:

    <?php
    $type = 'sf1_artist';
    $args=array(
      'post_type' => $type,
      'post_status' => 'publish',
      'paged' => $paged,
      'posts_per_page' => 4,
      'caller_get_posts'=> 1
    );
    $temp = $wp_query;  // assign orginal query to temp variable for later use
    $wp_query = null;
    $wp_query = new WP_Query($args); 
    
    get_template_part( 'loop', 'artists' );
    ?>

    for more info check these:
    https://codex.www.ads-software.com/Function_Reference/WP_Query
    https://codex.www.ads-software.com/The_Loop

    Forum: Plugins
    In reply to: Custom Post Type Parent

    I too have the same problem and couldn’t find anything to help.

    As a dirty, temporary solution (hope someone finds one!) I’ve used javascript and jQuery to change the selected menu item, hope it helps ??

    <!-- Dirty hack to change current menu item (current_page_parent) -->
    <script type="text/javascript" language="javascript">
    $(document).ready( function (){
    
    	// change this with the menu ID which SHOULDN'T be selected.
    	var temp = $('#menu-item-34').attr('class');
    
    	// removes 'current_page_parent' class from current selected menu item.
    	temp = temp.replace("current_page_parent ", "");
    	$('#menu-item-34').attr('class', temp);
    
    	// change this with the menu ID which SHOULD be selected.
    	temp = $('#menu-item-43').attr('class');
    
    	// adds 'current_page_parent' class to desired menu item.
    	temp = "current_page_parent " + temp;
    	$('#menu-item-43').attr('class',temp);
    
    });
    </script>
Viewing 4 replies - 1 through 4 (of 4 total)