Forum Replies Created

Viewing 15 posts - 46 through 60 (of 125 total)
  • Author
    Posts
  • in reply to: [possible bug] select field with scope=post #6580
    mcmaster
    Member

    There’s no error message, but the value remains whatever it was before. I can change it to another non-zero value but not zero.

    I have the error isolated on a test site; would you like access to it?

    in reply to: [possible bug] select field with scope=post #6572
    mcmaster
    Member

    p.s. Should have mentioned that I’m using Piklist 0.9.9.8

    mcmaster
    Member

    Kevin explained that because a form can now create multiple objects, the ID field doesn’t work any more. He suggested using a couple of hooks to grab the ID and stick it into the redirect URL. Here are the functions that did the job. (If you’re not doing a redirect, you’ll just need the first one.)

    add_action( 'piklist_save_field-post', 'my_grab_new_post_id' );
    function my_grab_new_post_id ( $fields ) {
    	global $mcw_new_post_id;
    	$my_new_post_id = $fields['ID']['object_id'];
    }
    
    add_filter( 'wp_redirect', 'my_stick_new_post_id_in_redirect', 10, 2 );
    function my_stick_new_post_id_in_redirect ( $location, $status ) {
    	global $my_new_post_id;
    	return( $location."?ID=$my_new_post_id" );
    }
    
    mcmaster
    Member

    Posted $_RESULT for the simplified form:

    Array
    (
        [_post] => Array
            (
                [post_type] => ticket
                [post_status] => draft
                [post_title] => Donna Test
                [ID] => 
            )
    
        [_post_meta] => Array
            (
                [phone] => 555-555-1212
            )
    
        [submit] => Review Order
        [_] => Array
            (
                [form_id] => theme_ticket_order_form
                [nonce] => 409df09d78
                [fields] => 77fa371f86f4a61bb87df398d2260f27
            )
    
    )
    
    mcmaster
    Member

    I just simplified the form as it had a lot of code used to figure out what the ticketable events are:

    <?php
    /*  
    Title: Test Order Form
    Method: post
    Message: Data saved as a post of type ticket.
    */
    
    // Set where to save this form
    piklist('field', array(
    	'type' => 'hidden',
    	'scope' => 'post',
    	'field' => 'post_type',
    	'value' => 'ticket',
    ));
    
    piklist('field', array(
    	'type' => 'hidden',
    	'scope' => 'post',
    	'field' => 'post_status',
    	'value' => 'draft',
    ));
    
    // Collect information
    piklist('field', array(
    	'type' => 'text',
    	'scope' => 'post', // post_title is in the wp_posts table
    	'field' => 'post_title',
    	'label' => 'Name',
    	'columns' => 10,
    	'required' => true
    ));
    
    piklist('field', array(
    	'type' => 'text',
    	'scope' => 'post_meta',
    	'field' => 'phone',
    	'label' => 'Phone',
    	'columns' => 10,
    	'required' => true,
    ));
    
    // New post ID
    piklist('field', array(
    	'type' => 'hidden',
    	'field' => 'ID',
    	'scope' => 'post',
    	'required' => false,
    ));
    
    // Submit button
    piklist('field', array(
    	'type' => 'submit',
    	'field' => 'submit',
    	'value' => 'Review Order',
    	'attributes' => array(
    		'class' => 'btn btn-default',
    	),
    ));
    
    mcmaster
    Member

    Jason, thanks so much! The ID is not in either. I started looking at $_POST and then switched to $_REQUEST to make sure I wasn’t missing anything in $_GET. But nothing is coming via $_GET.

    I started out using a redirect field, but I was receiving nothing at the target, so then I removed the redirect and just put a piklist::pre( $_REQUEST ) in the beginning of the form page. Here’s what I get:

    Array
    (
        [_post] => Array
            (
                [post_type] => ticket
                [post_status] => draft
                [post_title] => Donna Test
                [ID] => 
            )
    
        [_post_meta] => Array
            (
                [phone] => 541-738-2973
                [email] => [email protected]
                [tickets_season] => Array
                    (
                        [0] => 2
                    )
    
                [tickets_c1878] => Array
                    (
                        [0] => 0
                    )
    
                [tickets_c1897] => Array
                    (
                        [0] => 0
                    )
    
                [tickets_c1899] => Array
                    (
                        [0] => 0
                    )
    
                [tickets_c1931] => Array
                    (
                        [0] => 1
                    )
    
                [donation] => 
                [address_1] => 123 X
                [address_2] => 
                [city_state] => Portland OR
                [total_due] => 130
                [total_paid] => 0
            )
    
        [submit] => Review Order
        [_] => Array
            (
                [form_id] => theme_ticket_order_form
                [nonce] => 19175e9a65
                [fields] => 6615d42e5a870dacde95e626deea7ee2
            )
    
    )

    That’s when I have the hidden ID field in the form; if I remove that field I have no ID column in the _post array.

    Donna

    in reply to: Shortcode UI #6257
    mcmaster
    Member
    in reply to: [0.9.9.6] shortcode interface not working with IIS #6168
    mcmaster
    Member

    No, thankfully my client decided to move to a Linux server. 🙂

    I talked with Kevin Miller (Piklist developer) and he thought he had a fix. Evidently it will be in the next release but I don’t know when that’s coming out.

    Donna

    in reply to: excerpt metabox disappears when WYSIWYG enabled #5646
    mcmaster
    Member

    Thanks, Steve! Tested v1.9.4 and it’s fixed the problem.

    Donna

    in reply to: Hide Workflow Tabs For Specific Page #5587
    mcmaster
    Member

    Hi, this is the same question as was asked here:

    limiting workflow to specific post ID or template

    And it was answered with a pointer to here:

    show fields conditioned on taxonomy term?

    And I believe the latter was left as something that will be fixed in the next release.

    in reply to: [0.9.9.6] Add more problem #5561
    mcmaster
    Member

    Steve, I’ve been having this problem for some time. I’ve been able to recover data by editing the serialized string in the database to “close up” the array.

    I just went through that exercise again, but this time there was a twist. The value was double serialized.

    
    s:3388:"a:17:{i:0;a:5:{s:16:"feature_headline";s:17:"Jan Charten-Brawn";s:13:"feature_image";a:1:{i:0;s:3:"330";}s:12:"feature_text";s:9:"President";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";}
    ...
    i:16;a:5:{s:16:"feature_headline";s:10:"Donny Lane";s:13:"feature_image";a:1:{i:0;s:3:"336";}s:12:"feature_text";s:8:"Director";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";}}";
    

    I had to remove the extra serialization wrapper in addition to fixing the indices:

    
    a:17:{i:0;a:5:{s:16:"feature_headline";s:17:"Jan Charten-Brawn";s:13:"feature_image";a:1:{i:0;s:3:"330";}s:12:"feature_text";s:9:"President";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";}
    ...
    i:16;a:5:{s:16:"feature_headline";s:10:"Donny Lane";s:13:"feature_image";a:1:{i:0;s:3:"336";}s:12:"feature_text";s:8:"Director";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";}}
    

    Hope this may be helpful to someone else as we wait for 1.0. 😉

    Donna

    in reply to: show metabox only for top-level pages #5423
    mcmaster
    Member

    Yes, it’s clear that tutorial at https://piklist.com/user-guide/tutorials/hide-meta-boxes-page-template/ needs updating. Neither piklist_get_file_data nor piklist_add_part filters are executed in 0.9.9.x.

    I think they may be replaced with piklist_part_data along with some of the variants in Piklist::process_parts, and also piklist_part_data_parameter? (See file plugins/piklist/includes/class-piklist.php.)

    No time to test right now, but let us know if you find the magic formula. 😉

    Cheers,
    Donna

    in reply to: quote marks in shortcodes #5422
    mcmaster
    Member

    I tried to fix this using Piklist sanitization. The function named in the piklist_sanitization_rules filter (mcw_sanitize_shortcode) was called, but the callback function (mcw_sanitize_shortcode_callback) never got executed.

    Did I do something wrong? Or does the shortcode interface not support sanitization rules?

    I created these filters and functions:

    
    /**
       keep shortcodes from barfing on " [ ] chars
     */
    add_filter( 'piklist_sanitization_rules', 'mcw_sanitize_shortcode', 11 );
    function mcw_sanitize_shortcode ( $sanitization_rules ) {
       $sanitization_rules['mcw_shortcode'] = array(
          'callback' => 'mcw_sanitize_shortcode_callback'
       );
       return $sanitization_rules;
    }
     
    function mcw_sanitize_shortcode_callback ( $value, $field, $options ) {   
       $reserved_chars = array( '"', '[', ']' );
       $encoded_chars = array( '&quot;', '&lsqb;', '&rsqb;' );
       $return = str_replace( $reserved_chars, $encoded_chars, $value );
       return $return;
    }
    
    function mcw_restore_shortcode_chars ( $encoded_value ) {   
       $encoded_chars = array( '&quot;', '&lsqb;', '&rsqb;' );
       $reserved_chars = array( '"', '[', ']' );
       return str_replace( $encoded_chars, $reserved_chars, $encoded_value );
    }
    

    And here’s my shortcode form:

    
    <?php
    /*
    Name: Two-Column Section
    Description: Create a 2-column section inside a page. 
    Shortcode: mcw-2column
    Icon: dashicons-controls-pause
    */
     
    piklist('field', array(
    	'type' => 'editor',
    	'field' => 'col_left',
    	'label' => 'Content for left column',
    	'columns' => 12,
    	'options' => array (
    		'media_buttons' => false,
    		'teeny' => true,
    	),
    	'sanitize' => array(
    		array(
    			'type' => 'mcw_shortcode',
    		),
    	),
    ));
    
    piklist('field', array(
    	'type' => 'editor',
    	'field' => 'col_right',
    	'label' => 'Content for left column',
    	'columns' => 12,
    	'options' => array (
    		'media_buttons' => false,
    		'teeny' => true,
    	),
    	'sanitize' => array(
    		array(
    			'type' => 'mcw_shortcode',
    		),
    	),
    ));
    

    and the shortcode output:

    
    <?php
    /*
    Shortcode: mcw-2column
    */
    
    	$left = apply_filters( 'the_content', mcw_restore_shortcode_chars( $col_left ) );
    	$right = apply_filters( 'the_content', mcw_restore_shortcode_chars( $col_right ) );
    ?>
    <div class="two-column row">
    	<div class="col-sm-6">
    		<?php echo $left; ?>
    	</div>
    	<div class="col-sm-6">
    		<?php echo $right; ?>
    	</div>
    </div>
    

    Thanks,
    Donna

    in reply to: show metabox only for top-level pages #5420
    mcmaster
    Member

    The beta I was using back then was 0.9.5.x, so it could have changed. The Gist URL has changed, BTW, it is now https://gist.github.com/donnamcmaster/7324cba06b375ef35b5b.

    in reply to: quote marks in shortcodes #5405
    mcmaster
    Member

    The problem also occurs with square brackets.

Viewing 15 posts - 46 through 60 (of 125 total)