But getting back to my point of Posts 2 Posts.
I'm trying to add a custom admin box to an input field. This is the example code they provide to build your own admin box.
Any direction how I would go about implementing this into the code beneath it?
add_action( 'init', 'init_my_connection_type', 100 );
add_action( 'add_meta_boxes', 'register_my_meta_box' );
function init_my_connection_type() {
p2p_register_connection_type( array(
'name' => 'posts_to_pages',
'from' => 'post',
'to' => 'page',
'admin_box' => false
) );
}
function register_my_meta_box() {
add_meta_box( 'my-box', 'My Connected Pages', 'render_my_meta_box', 'post' );
}
function render_my_meta_box( $post ) {
echo 'This is my box.';
$ctype = p2p_type( 'posts_to_pages' )->get_connected( $post );
?>
<ul>
<?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php
}
and..
add_action( "gform_field_input" , "wps_tos_field_input", 10, 5 );
function wps_tos_field_input ( $input, $field, $value, $lead_id, $form_id ){
if ( $field["type"] == "c_cpt" ) {
$max_chars = "";
if(!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"]))
$max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
$input_name = $form_id .'_' . $field["id"];
$tabindex = GFCommon::get_tabindex();
$css = isset( $field['cssClass'] ) ? $field['cssClass'] : '';
return sprintf("<div class='ginput_container'><textarea readonly name='input_%s' id='%s' class='textarea gform_tos %s' $tabindex rows='10' cols='50'>%s</textarea></div>{$max_chars}", $field["id"], 'ccpt-'.$field['id'] , $field["type"] . ' ' . esc_attr( $css ) . ' ' . $field['size'] , esc_html($value));
}
return $input;
}
Posted 12 years ago on Monday August 6, 2012 |
Permalink