Forum Replies Created

Viewing 15 replies - 31 through 45 (of 61 total)
  • Thread Starter IoClaudio

    (@ioclaudio)

    Thank you for the link.
    I’ve tried it and I don’t like two things:
    – each child instance uses the same database as the father, adding its own tables.
    – the administrator of a site can’t activate or deactivate a plugin, only the network administrator can do this.

    I would prefer that each instance has its own database and that the plugin are shared but each instance can activate or not activate them.
    However, it is good that the network administrator has an interface to manage all the other instances.
    We should evaluate the pros and the cons and make a decision.
    Thank you.

    cld

    • This reply was modified 3 years, 9 months ago by IoClaudio.
    Thread Starter IoClaudio

    (@ioclaudio)

    I think I’ve found the solution into the code of the ACF plugin:

    // Vars.
    $slug = 'edit.php?post_type=acf-field-group';
    $cap  = acf_get_setting( 'capability' );
    
    // Add menu items.
    add_menu_page( __( 'Custom Fields', 'acf' ), __( 'Custom Fields', 'acf' ), $cap, $slug, false, 'dashicons-welcome-widgets-menus', 80 );
    add_submenu_page( $slug, __( 'Field Groups', 'acf' ), __( 'Field Groups', 'acf' ), $cap, $slug );
    add_submenu_page( $slug, __( 'Add New', 'acf' ), __( 'Add New', 'acf' ), $cap, 'post-new.php?post_type=acf-field-group' );
    • This reply was modified 3 years, 9 months ago by IoClaudio.
    Thread Starter IoClaudio

    (@ioclaudio)

    In this function:

    function emt_course_template( $single )

    when emt_course_template is called if WordPress has found the file in the theme directory I have the value in the $single parameter and I do nothing.
    If the theme doesn’t have the template then the $single parameter is an empty string.

    So I don’t understand why that guy writes this code:

    if ( 'movie' === $post->post_type && locate_template( array( 'single-movie.php' ) ) !== $template )

    Thread Starter IoClaudio

    (@ioclaudio)

    Thank you.
    Based on that example I wrote this function.
    It seems to work as expected.

    /**
     * Finds the template of the Course post type.
     *
     * @param [String] $single - The path of the template found.
     * @return [String] - The path of the template to use.
     */
    function emt_course_template( $single ) {
    	global $post;
    	$template = 'single-emt-course.php';
    
    	/* If the $template exists in the theme folder use it otherwise use the one defined in the plugin */
    	if ( COURSE_POST_TYPE === $post->post_type && '' !== $single ) {
    		return $single;
    	} else if ( file_exists( plugin_dir_path( __FILE__ ) . '/' . $template ) ) {
    			return plugin_dir_path( __FILE__ ) . '/' . $template;
    	}
    	return $single;
    }

    So if a theme redefines the template that file is used, otherwise is used the plugin’s template.

    cld

    Thread Starter IoClaudio

    (@ioclaudio)

    Ok, thank I think this is what I’m looking for.

    Thread Starter IoClaudio

    (@ioclaudio)

    Hi,
    I’ve used this code to read the XML message.
    It seems to work:

    
    $result   = trim( file_get_contents( 'php://input' ) );
    $xml      = preg_replace( '/(<\/?)(\w+):([^>]*>)/', '$1$2$3', $result );
    $xml      = simplexml_load_string( $xml );
    $json     = wp_json_encode( $xml );
    $response = json_decode( $json, true );
    Thread Starter IoClaudio

    (@ioclaudio)

    Hi,
    yes I have a configuration page for the plugin.
    However I’d like to have a page in the WooCommerce menu that shows transactions.
    After some search in the web I think I will use WP_list_table:
    https://developer.wordpress.org/reference/classes/wp_list_table/

    cld

    Thread Starter IoClaudio

    (@ioclaudio)

    Thank you very much.
    I didn’t knows those resources.

    cld

    Thread Starter IoClaudio

    (@ioclaudio)

    Ok, but how can I schedule the execution of a hook? I have to call it from a cron job of the operating sytem?

    cld

    Thread Starter IoClaudio

    (@ioclaudio)

    Hi,
    I’ve defined this filter in a custom plugin and it seems to work:

    function wp_custom_http_origin_filter($title)
    {
        return '*';
    }
    add_filter('http_origin', 'wp_custom_http_origin_filter');
    

    Thank you

    cld

    • This reply was modified 6 years, 3 months ago by IoClaudio.
    Thread Starter IoClaudio

    (@ioclaudio)

    Hi,
    I don’t think is the best solution, but I’ve solved in this way:

    vi wp-content/plugins/ba-book-everything/js/admin/babe-admin-prices.js

    I have modified this:

                if (msg != ''){
                  $('#publish').css('display', 'inline-block');
                } else {
                  $('#publish').css('display', 'none');  
                }

    in this way:

                if (msg != ''){
                  $('#publish').css('display', 'inline-block');
                } else {
                  // $('#publish').css('display', 'none');  
                }
    Thread Starter IoClaudio

    (@ioclaudio)

    function my_acf_prepare_field( $field ) {
        error_log("######".json_encode($field["value"])."######");
        $l_defaultTable = '{"acftf":{"v":"1.3.9"},"p":{"o":{"uh":1},"ca":""},"c":[{"p":""},{"p":""},{"p":""},{"p":""},{"p":""},{"p":""}],"h":[{"c":"Data"},{"c":"Orario"},{"c":"Tipologia"},{"c":"Preiscrizioni"},{"c":"Iscrizioni"},{"c":"Risultati"}],"b":[[{"c":""},{"c":""},{"c":""},{"c":""},{"c":""},{"c":""}]]}';
        if ($field["value"]==null) {
            error_log("@@@ Trovato NULL @@@");
            $field["value"] = $l_defaultTable;
        } else if (is_array($field["value"])) {
            $l_jsonString = json_encode($field["value"]);
            if (strpos($l_jsonString, 'Data') == false) {
                $field["value"] = $l_defaultTable;
            }
        } else {
            error_log("@@@ Non trovato NULL @@@");
        }
        return $field;
    }
    • This reply was modified 6 years, 4 months ago by IoClaudio.
    Thread Starter IoClaudio

    (@ioclaudio)

    Thank you, but is this a new feature? Because I’ve always saved the booking objects without rates.
    Is there a way to add a default rate or a way to not have this field as mandatory?
    Thank you

    Thread Starter IoClaudio

    (@ioclaudio)

    Yes, I just want to pre-populate an input field during the first edit of a post.
    You’re right the better thing is to find a method to run a Javascript when the page opens.
    However it would be nice to have for all the fields an event like the one implemented for ACF, acf-prepare_field:”This filter allows you to modify a field right before it is rendered onto the page. By this time, the field has been validated and it’s value loaded.”

    thank you
    cld

    Thread Starter IoClaudio

    (@ioclaudio)

    I don’t mean a sort of hidden field, but a visible field whose content is “proposed” to the user.
    It could be a standard request for a field it would be nice to have a hook for this.
    Yes, the post type is always the same.
    However, since I was using Advanced Custom Fields I used this hook with some conditions:
    https://www.advancedcustomfields.com/resources/acf-prepare_field/
    It seems to work.

    It would be nice do the same thing with all the fields.

    cld

    • This reply was modified 6 years, 4 months ago by IoClaudio.
    • This reply was modified 6 years, 4 months ago by IoClaudio.
Viewing 15 replies - 31 through 45 (of 61 total)