Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter joediego

    (@joediego)

    
    <?php
    function chat_bot_conversational() {
    
    	$args = array(
    		'id'           => 'principal_bot_response',
    		'title'        => 'Principal',
    		'object_types' => array( 'options-page' ),
    		// 'admin_menu_hook' => 'network_admin_menu' // NOT WORKING,
    		'option_key'   => 'bot_conv',
    	);
    
    	if ( version_compare( CMB2_VERSION, '2.4.0' ) ) {
    		$args['display_cb'] = 'bots_responses';
    	}
    	$main_options = new_cmb2_box( $args );
    	$group_id = $main_options->add_field( array(
    		'id'                => 'questoes_multisite',
    		'type'              => 'group',
    		'description'       => 'Perguntas ',
    		'options'           => array(
    			'group_title'   => 'Questão {#}',
    			'add_button'    => 'Adicionar Questão',
    			'remove_button' => 'Remover Questão',
    			'sortable'      => true
    		)
    	));
    	$main_options->add_group_field( $group_id, array(
    		'name' => 'Nome do Campo',
    		'id'   => 'nome',
    		'type' => 'text',
    	));
    	$main_options->add_group_field( $group_id, array(
    		'name' => 'Questão',
    		'id'   => 'questao',
    		'type' => 'textarea_small',
    	));
    	$main_options->add_group_field( $group_id, array(
    		'name' => 'Grupo',
    		'id'   => 'grupo',
    		'type' => 'text',
    	));
    	$main_options->add_group_field( $group_id, array(
    		'id'            => 'opcoes_pergunta',
    		'name'          => __('Opções ', 'opcoes'),
    		'type'          => 'text',
    		'sortable'      => true,
    		'repeatable'     => true,
    	));
    }
    function myprefix_get_option( $key = '', $default = false ) {
    	if ( function_exists( 'cmb2_get_option' ) ) {
    		return cmb2_get_option( 'bot_conv', $key, $default );
    	}
    	// Fallback to get_option if CMB2 is not loaded yet.
    	$opts = get_option( 'bot_conv', $default );
    
    	$val = $default;
    
    	if ( 'all' == $key ) {
    		$val = $opts;
    	} elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) {
    		$val = $opts[ $key ];
    	}
    
    	return $val;
    }
    add_action( 'cmb2_admin_init', 'chat_bot_conversational' );
    function foobar_func( $atts ){
    	$bla = get_option( 'bot_conv');
    	print_r($bla);
    	return $bla;
    }
    add_shortcode( 'foobar', 'foobar_func' );
    
    

    Network Multisite dont work!!
    How i can Make this?!?!

    • This reply was modified 5 years, 11 months ago by joediego.
    Thread Starter joediego

    (@joediego)

    I will try!, Thanks!!

    Thread Starter joediego

    (@joediego)

    function retorna_todos_equipamentos(){
    $list = array();
    $args = array(
    ‘post_type’ => ‘equipamentos’,
    ‘posts_per_page’ => -1,
    );
    $wp_query = new WP_Query($args);
    $equipamentos = $wp_query->posts;
    wp_reset_postdata();
    foreach ($equipamentos as $value) {
    $obj = array(‘id’ => $value->ID,’titulo’ => $value->post_name);
    array_push($lista,$obj);
    }
    return $lista;
    }

    ???

    Thread Starter joediego

    (@joediego)

    I’m sorry I’m new to wordpress, could you send me an example code?

    Thread Starter joediego

    (@joediego)

    I solved using wpquery!

    Thread Starter joediego

    (@joediego)

    I liked filter my custom_posttype with my custom field..

    `
    <?php global $post;
    $args = array( ‘post_type’ => ‘my-custom-post-type’,
    how make this filter????
    ‘meta_query’ => array(
    ‘key’ => ‘my_custom_field’,//my checkbox create with CMB2
    ‘value’ => ‘checked’
    ),
    );
    $mor_vend = get_posts( $args );
    foreach ( $mor_vend as $post ) : ?>
    <h1><?php the_title(); ?></h1>
    <?php endforeach;
    wp_reset_postdata(); ?>

    `

    Thread Starter joediego

    (@joediego)

    thanks giu uys

    Thread Starter joediego

    (@joediego)

    I ‘m registred new sidebar with this code.
    `register_sidebar(
    array(
    ‘name’ => __( ‘MY SIDE 01’, ‘rmcontact’ ),
    ‘id’ => ‘mysidebar’,
    ‘description’ => __( ‘MYSIDE 01’, ‘rmcontact’ ),
    ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ‘<h2 class=”widget-titulo”>’,
    ‘after_title’ => ‘</h2>’,
    )
    );

    how i can create custom fields using CMB2 in my sidebar?

    • This reply was modified 8 years, 4 months ago by joediego.
Viewing 8 replies - 1 through 8 (of 8 total)