Forum Replies Created

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter gavimobile

    (@gavimobile)

    s3w47m88,
    This thread was created 5 months ago and I don’t remember what I did. Do you really need to know the difference between the two? I shared the second one because that was the working solution. I always attempt to help others by showing the code that I used to get things working. In addition, I added lots of comments which should explain things! Let me know if you need to know the difference between the working one and the non working one and it i have time ill go through It and see if I can find something. A

    Thread Starter gavimobile

    (@gavimobile)

    s3w47m88!
    please note that this thread is marked as resolved!

    thanks anyways ??

    Thread Starter gavimobile

    (@gavimobile)

    like!!! glad i was able to help!

    Thread Starter gavimobile

    (@gavimobile)

    i think the add_action function args to be properly configured. if ANYONE can give an example of how i can loop this i would surly be grateful. sorry for the bump.

    Thread Starter gavimobile

    (@gavimobile)

    i can do this with eval() but i know its not recommeneded

    Thread Starter gavimobile

    (@gavimobile)

    Glad I Was helpful! Seems like you got the hang of it! Thanks for your additional example! I hope someone else may find it helpful!

    Thread Starter gavimobile

    (@gavimobile)

    i decided not to use this plugin. instead im creating my own! thanks

    Chase. thanks for the tip! just saw your post now.
    s1ngular1ty, has your issue been solved? it would be great if you can set the status of this topic to resolved unless your problem has not been solved yet.

    Thread Starter gavimobile

    (@gavimobile)

    Thanks for the feedback abd inspiration Marcus!

    Thread Starter gavimobile

    (@gavimobile)

    i got it folks! i will provide you with my example of how i successfully created the custom placeholder. the example in the links were a bit confusing for me.

    here we go, just add the code to your functions.php file. no need to edit the plugin as we all agreed was a bad idea.

    //creating a custom placeholder
    //create the filter. the website will search for our placeholder using this function
    add_filter('em_event_output_placeholder','my_em_styles_placeholders',1,3); // change the name of the function from em_event_output_placeholder to em_events_something
    function my_em_styles_placeholders($replace, $EM_Event, $result){ //make sure you change the name of the function to em_events_something
    	global $wp_query, $wp_rewrite;
    	switch( $result ){
    		case '#_MYEXCERPT': // name of the placeholder
    			$replace = $EM_Event->output("#_EVENTNOTES"); //lets retrieve the original event data so we can modify it
    			$replace = preg_replace('/<img[^>]+./','', $replace); // make the modification of taking out any images
    			if($result == "#_MYEXCERPT"){  //heres what we are goign to do if the placeholder has been found
    				$length = 25; //length of word for (the excerpt)
    				$replace = implode(' ',array_slice(explode(' ', $replace),0,$length)); //apply the length amount to the output
    				$replace = $replace . '...'; //add 3 periods after lenth has been reached
    			}
    		break; // end the case
    	}
    	return $replace; //output the placeholder
    }

    would love to know if this was helpful to someone

    mspencer, it was created for custom post type named products. Channing where it says products to page or post on line 5 will allow this code to work for both pages or posts.
    I need to rewrite my comments, they were built off of other scripts/tutorials I found online and applied it for my needs.
    I will check out that function to see what it can do. Thanks

    Thread Starter gavimobile

    (@gavimobile)

    as i was continuing with my reading, it seems im going to need to use an array. also, only 1 hidden field is required. wasnt sure what its purpose was untill now. maybe someone can show me a better example of this as an array! it would help me understand it better. also i would still like to know about if i need to do any kind of escaping.

    thanks

    Thread Starter gavimobile

    (@gavimobile)

    wow, cant believe i missed it. here is a sample code to allow multiple visual editors (wp_editor or wysiwyg) using tinymce within a metabox.
    this will add the metabox to post’s

    <?php
    add_action( 'add_meta_boxes', 'mpc_add_description_meta_box' );
    // Add the products Meta Box
    function mpc_add_description_meta_box() {
        add_meta_box('mpc_add_description_meta_box', 'Product Description (Language 2)', 'mpc_add_description_meta_box_callback', 'post', 'normal', 'high');
    }
    
    // the description output
    function mpc_add_description_meta_box_callback() {
        global $post;
        // Noncename needed to verify where the data originated
        echo '<input type="hidden" name="mpc_products_description_noncename" id="mpc_products_description_noncename" value="'.wp_create_nonce(plugin_basename(__FILE__)).'" />';
        // Get the location data if its already been entered
        $input = get_post_meta($post->ID, 'mpc_products_description', true);
       // echo '<input type="text" name="mpc_products_description" value="' . $input  . '" "  />';
    	wp_editor($input, 'mpc_products_description', array('textarea_name' => 'mpc_products_description', 'editor_css' => '<style>#wp-mpc_products_description-editor-container{background-color:white;style="width:100%;}</style>'));
    
    	echo '<table id="post-status-info" cellspacing="0"><tbody><tr><td id="wp-word-count">Word count: <span class="word-count_2">';
    	$words = strip_tags($input);
    	$count = str_word_count($words, 0);
    	echo $count;
    	echo '</span></td>
    	<td class="autosave-info">
    	<span class="autosave-message">&nbsp;</span>
    	</td>
    	</tr></tbody></table>';
    }
    
    //save the data
    add_action('save_post', 'mpc_save_description_meta', 1, 2); // save the custom fields
    function mpc_save_description_meta($post_id, $post) {
        // verify this came from the our screen and with proper authorization,
        // because save_post can be triggered at other times
        if ( !wp_verify_nonce( $_POST['mpc_products_description_noncename'], plugin_basename(__FILE__) )) {
        return $post->ID;
        }
        // Is the user allowed to edit the post or page?
        if ( !current_user_can( 'edit_post', $post->ID ))
            return $post->ID;
        // OK, we're authenticated: we need to find and save the data
        // We'll put it into an array to make it easier to loop though.
        $mpc_description_meta['mpc_products_description'] = $_POST['mpc_products_description'];
        // Add values of $mpc_description_meta as custom fields
        foreach ($mpc_description_meta as $key => $value) { // Cycle through the $mpc_description_meta array!
            if( $post->post_type == 'revision' ) return; // Don't store custom data twice
            $value = implode(',', (array)$value); // If $value is an array, make it a CSV (unlikely)
            if(get_post_meta($post->ID, $key, FALSE)) { // If the custom field already has a value
                update_post_meta($post->ID, $key, $value);
            } else { // If the custom field doesn't have a value
                add_post_meta($post->ID, $key, $value);
            }
            if(!$value) delete_post_meta($post->ID, $key); // Delete if blank
        }
    }
    ?>

    ok, i got it! here is an example of a meta box with a tinymce editor or visual edior in the post_type. i have not spotted an issue yet. seems to be working flawless!.

    <?php
    add_action( 'add_meta_boxes', 'mpc_add_description_meta_box' );
    // Add the products Meta Box
    function mpc_add_description_meta_box() {
        add_meta_box('mpc_add_description_meta_box', 'Product Description (Language 2)', 'mpc_add_description_meta_box_callback', 'products', 'normal', 'high');
    }
    
    // the description output
    function mpc_add_description_meta_box_callback() {
        global $post;
        // Noncename needed to verify where the data originated
        echo '<input type="hidden" name="mpc_products_description_noncename" id="mpc_products_description_noncename" value="'.wp_create_nonce(plugin_basename(__FILE__)).'" />';
        // Get the location data if its already been entered
        $input = get_post_meta($post->ID, 'mpc_products_description', true);
       // echo '<input type="text" name="mpc_products_description" value="' . $input  . '" "  />';
    	wp_editor($input, 'mpc_products_description', array('textarea_name' => 'mpc_products_description', 'editor_css' => '<style>#wp-mpc_products_description-editor-container{background-color:white;style="width:100%;}</style>'));
    
    	echo '<table id="post-status-info" cellspacing="0"><tbody><tr><td id="wp-word-count">Word count: <span class="word-count_2">';
    	$words = strip_tags($input);
    	$count = str_word_count($words, 0);
    	echo $count;
    	echo '</span></td>
    	<td class="autosave-info">
    	<span class="autosave-message">&nbsp;</span>
    	</td>
    	</tr></tbody></table>';
    }
    
    //save the data
    add_action('save_post', 'mpc_save_description_meta', 1, 2); // save the custom fields
    function mpc_save_description_meta($post_id, $post) {
        // verify this came from the our screen and with proper authorization,
        // because save_post can be triggered at other times
        if ( !wp_verify_nonce( $_POST['mpc_products_description_noncename'], plugin_basename(__FILE__) )) {
        return $post->ID;
        }
        // Is the user allowed to edit the post or page?
        if ( !current_user_can( 'edit_post', $post->ID ))
            return $post->ID;
        // OK, we're authenticated: we need to find and save the data
        // We'll put it into an array to make it easier to loop though.
        $mpc_description_meta['mpc_products_description'] = $_POST['mpc_products_description'];
        // Add values of $mpc_description_meta as custom fields
        foreach ($mpc_description_meta as $key => $value) { // Cycle through the $mpc_description_meta array!
            if( $post->post_type == 'revision' ) return; // Don't store custom data twice
            $value = implode(',', (array)$value); // If $value is an array, make it a CSV (unlikely)
            if(get_post_meta($post->ID, $key, FALSE)) { // If the custom field already has a value
                update_post_meta($post->ID, $key, $value);
            } else { // If the custom field doesn't have a value
                add_post_meta($post->ID, $key, $value);
            }
            if(!$value) delete_post_meta($post->ID, $key); // Delete if blank
        }
    }
    ?>

    Thread Starter gavimobile

    (@gavimobile)

    Marcus, Your absolutely right. I’m going to try and play around with that tomorrow
    Thanks for your prompt response

Viewing 15 replies - 1 through 15 (of 16 total)