Forum Replies Created

Viewing 15 replies - 16 through 30 (of 46 total)
  • Thread Starter Ken Stone

    (@wpstoneblue)

    Failing to visit the permalinks screen or flush rewrite rules will certainly prevent your CPT from being properly queried. It doesn’t have any direct bearing on whether template filters fire. However, if the query fails, the 404 template is loaded and the remaining template determination sequence with its related filters are all passed over. Only the generic “template_include” filter still fires.

    Yes, this is exactly what I was seeing the 404 and only the template_include filter firing.

    For the archive I ended up with the following working code and very similar for the single:

     public function stoneblue_thinkific_archive_template($template){
    
        global $post;
    
        if ($post->post_type == "stoneblue-thinkific" 
           && $template !== locate_template(array("archive-stoneblue-thinkific.php"))){
                            
           $file = dirname(dirname(__FILE__)) . '/stoneblue-thinkific.php';
                            
           $template = plugin_dir_path($file) . 'templates/archive-stoneblue-thinkific.php';
        }
    
    }
    Thread Starter Ken Stone

    (@wpstoneblue)

    Ugh, could this be because I failed to visit the settings – perma links admin page ?

    Thread Starter Ken Stone

    (@wpstoneblue)

    It’s just not my day, that’s all there is to it…

    Backing up a bit the CPT is defined as:

     $rpt_arg = array(
       'labels' => array(
          'name'            => __( 'Thinkific Course', $this->plugin_name ),
          'singular_name'   => __( 'Thinkific Course', $this->plugin_name ),
          'menu_na          => __( 'Thinkific Courses', $this->plugin_name ),
          'name_admin_bar'  => __( 'Thinkific Courses', $this->plugin_name ),
          'add_new'         => __( 'Thinkific Course', $this->plugin_name ),
          'add_new_item'    => __( 'Thinkific Course', $this->plugin_name ),
          'new_ite          => __( 'Thinkific Course', $this->plugin_name ),
          'not_found'       => __( 'Thinkific Course  Not Found', $this->plugin_name ),
          'all_items'       => __( 'All Thinkific Courses', $this->plugin_name ),
                            ),
        'public'              => true,
        'show_in_menu'        => true,
        'has_archive'         => true,
        'supports'            => array('title', 'editor', 'thumbnail'),
        'rewrite'             => true,
        'map_meta_cap'        => true,
        'register_meta_box_cb'  => array($this, 'add_meta_boxes')
        );
    
    $post_type = register_post_type('stoneblue-thinkific', $rpt_arg);

    single_template and archive_template filters are not getting called for the CPT so appears that I can’t use them.

    I really don’t want to use template_include but …

    Thread Starter Ken Stone

    (@wpstoneblue)

    Thanks! I will try the {$type}_template_hierarchy filter now to explore that possibility.

    My goal is to load the single and archive templates for the CPT from the plugin directory.

    I was attempting to following along with this https://wpshout.com/hacking-the-wordpress-template-hierarchys/ example.

    Thread Starter Ken Stone

    (@wpstoneblue)

    I still have no idea how to do it within the PHP SOAP library so I went ahead and just rolled my own XML for now.

    
    public function get_xml($method, $type, $data_assoc_array){
    
            $my_xml = '<ns1:' . $method . '><ns1:'. $type . '>';
    
            foreach($data_assoc_array as $key => $val){
                $my_xml .= '<ns1:' . $key . '>' . $val . '</ns1:' . $key . '>';
            }
    
            $my_xml .= '</ns1:' . $type . '></ns1:' . $method . '>';
    
            return $my_xml;
        }
    
    Thread Starter Ken Stone

    (@wpstoneblue)

    I have a similar issue now when calling a method that has parameters in the body.

    PHP SOAP is using xsi:type=”ns1… instead of adding ns1 to each value in the parameter object. Does anyone know if there is a way to modify this behavior?

    
    <SOAP-ENV:Body>
    <ns1:Process_Credit_Application xsi:type="ns1:obj_Credit_Application">
    <ApplicantIP>192.168.1.1</ApplicantIP>
    

    I think what is needed is:

    
    <SOAP-ENV:Body>
    <ns1:Process_Credit_Application>
    <ns1:obj_Credit_Application>
    <ns1:ApplicantIP>192.168.1.1</ns1:ApplicantIP>
    
    • This reply was modified 6 years, 8 months ago by Ken Stone.
    Thread Starter Ken Stone

    (@wpstoneblue)

    Hi Dion,

    I have:

    
    'cache_wsdl' => WSDL_CACHE_NONE,
    

    in the instantiation of the soap client.

    Working now. but THANKS

    Thread Starter Ken Stone

    (@wpstoneblue)

    At this point though I’m wondering since the online SOAP client at wsdlbrowser.com created the same XML as the PHP code based on the WSDL file if there is some issue with the WSDL file?

    Thread Starter Ken Stone

    (@wpstoneblue)

    Got it working:

    I removed the soapvar from the header and just use the PHP class straight away.

    The difference is that now

     
    <env:Header>
    <ns1:User_Credentials>
    <ns1:str_Username>jklsafdljk</ns1:str_Username>
    <ns1:str_Password>jkasdjl</ns1:str_Password>
    </ns1:User_Credentials>
    </env:Header>
    

    ns1 is also on the username and password
    where previously it was not:

    
    <SOAP-ENV:Header>
    <ns1:User_Credentials>
    <str_Username>asdasdasd</str_Username>
    <str_Password>asdasdads</str_Password>
    </ns1:User_Credentials>
    </SOAP-ENV:Header>
    

    I got a clue from a google search result. I didn’t even click through but I saw ‘you don’t have to use a soapvar in the header you can use a regular php class’. At this point I was willing to try anything…

    So I immediately did

    
    //$header = new SoapHeader($tns, 'User_Credentials', $authvalues, false);
    $header = new SoapHeader($tns, 'User_Credentials', $User_Credentials, false);
    
    • This reply was modified 6 years, 8 months ago by Ken Stone.
    Thread Starter Ken Stone

    (@wpstoneblue)

    If I use the online https://wsdlbrowser.com/
    and enter the WSDL is also creates XML with the ns1 bound to the xmlns

    So I would think the ASP server should accept it but it doesn’t.

    • This reply was modified 6 years, 8 months ago by Ken Stone.
    Thread Starter Ken Stone

    (@wpstoneblue)

    Hi DionDesigns,

    Yes I’m using

    
    $client = new SoapClient($wsdl,
                                    array(
                                            'trace' => 1,
                                            'cache_wsdl' => WSDL_CACHE_NONE,
                                            'soap_version' => SOAP_1_2
                                    ));
    

    
      $authvalues = new SoapVar($User_Credentials, SOAP_ENC_OBJECT);
    

    
     $header = new SoapHeader($tns, 'User_Credentials', $authvalues, false);
    

    
     $client->__setSoapHeaders(array($header));
    
    

    
    $soapResponse = $client->Is_Alive();
    $lastRespHeaders = $client->__getLastResponseHeaders();
    $lastResquest = $client->__getLastRequest();
    $lastResponse = $client->__getLastResponse();
    
    

    but microsoft is not accepting ns1

    Thread Starter Ken Stone

    (@wpstoneblue)

    I ended up using the pre_get_posts hook:

    
    $this->loader->add_action('pre_get_posts', $plugin_admin, 'query_set_only_author');
    
    

    As time permits I’ll clean up the post counts at the top of the table

    
     public function query_set_only_author($query){
    
                    global $pagenow;
            
                    if('edit.php' != $pagenow) return $query;
                    
                    if( is_admin() && ProtectTheInnocent_Public::is_merchant() ) {
                            $curr_usr_id = get_current_user_id();
                            $query->set( 'author', $curr_usr_id );
                            //add_filter('views_edit-post', 'fix_post_counts');
                            //add_filter('views_upload', 'fix_media_counts');
                    }
                    
                    return $query;
                    
            }
    
    

    I’ve been using:

    
    jQuery(document).ready(function($){
    
            if($("#merchant_id_missing").length){
    
    

    with good success to allow the use of $. Is this OK to continue using this method ?

    In the shortcode handler be sure to buffer up all your output then return it.

    Thread Starter Ken Stone

    (@wpstoneblue)

    Actually just looking at the ‘supports’, probably don’t need editor.

    A customer fills out a form to publish a credit_app and the publisher is based on what they enter or by a query string in the URL so the CPTs are published by random people on the front end. So probably I just need title, author, and custom-fields.

Viewing 15 replies - 16 through 30 (of 46 total)