Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Sunny Johal

    (@sunny_johal)

    Hi George,
    Thanks for your question. It’s actually quite easy to add theme support for this plugin if you know some php. Here is a code example that you can use and adapt as necessary to add theme support (this would go in your themes functions.php file):

    function my_theme_egf_default_controls( $options ) {
    
        // Here's how to remove some default controls
        unset( $options['tt_default_heading_1'] );
        unset( $options['tt_default_heading_2'] );
        unset( $options['tt_default_heading_3'] );
        unset( $options['tt_default_heading_4'] );
        unset( $options['tt_default_heading_5'] );
        unset( $options['tt_default_heading_6'] );
    
        /**
         * Here is an example of adding our own custom theme
         * controls (the selectors used are arbitrary this
         * would change depending on the css element that
         * you want to control).
         */
        $options['my_themes_h1'] = array(
            'name'        => 'my_themes_h1',
            'title'       => 'My Themes H1 Elements',
            'description' => 'A description for my custom h1 control',
            'properties'  => array( 'selector' => 'h1, #sidebar h1' ),
        );
    
        $options['my_themes_widget_headings'] = array(
            'name'        => 'my_themes_widget_headings',
            'title'       => 'Widget Headings',
            'description' => 'Edit your widget headings',
            'properties'  => array( 'selector' => '.widget-title, h2.widget-title' ),
        );
    
        // Return the default controls
        return $options;
    }
    add_filter( 'tt_font_get_option_parameters', 'my_theme_egf_default_controls' );

    This is all that you would need to do, the controls will be available in the live previewer automatically! Hope that makes sense. Just adapt the example and make it specific to your theme.If you need any further help just give me a shout.

    Sunny

    Plugin Author Sunny Johal

    (@sunny_johal)

    Hi George,
    Did you manage to follow the response I left? Just give me a shout if you have any questions. Cheers

    Sunny

    Thread Starter george.grigorita

    (@georgegrigorita)

    Hi Sunny,

    Thanks for all the info, everything is clear. And sorry for the late response.

    Plugin Author Sunny Johal

    (@sunny_johal)

    Hi George,
    Thanks for getting back to me, I’m going to mark this post as resolved. If you have any other questions just give me a shout anytime. Cheers

    Sunny

    p.s was wondering if you could rate this plugin when you get a moment. thanks

    EDGE22

    (@midnightdonkey)

    Thanks for this.

    Just wondering if it’s possible to allow overriding through this function as well?

    How about removing certain aspects from our added sections? Like removing font color or background color for example?

    Is it possible to control the order so our added sections show up above the default ones?

    Tom

    Plugin Author Sunny Johal

    (@sunny_johal)

    Hi Tom,
    Currently it is not possible to show/hide controls within a font control. It is also not possible to control the order of the added sections. Any sections added via php appear in the order in which they are added and any font controls created in the admin panel are added in alphabetical order. Could you describe the reason why you want to do the things you listed above? If there is a good use case for it, I will consider implementing it in a future release.

    Sunny

    Hi Sunny,
    Thanks for this tip. Is there a way of assigning a “default” value to the settings?
    Alvaro

    Plugin Author Sunny Johal

    (@sunny_johal)

    Hi Alvaro,
    It is definitely possible to assign a default value to the settings. Can you give me an example of what you are trying to do so I can show you a code example. Cheers

    Sunny

    I am trying to adecuate my theme so it can be used with this plugin. I already followed your code up to add my custom controls. What Im asking for is to give this controls a default value. Right now when the plugin is activated, the value for each option (Font Family,Font Weight/Style,etc.) is –Theme Default–. Which way do I assign this Theme Default value?

    Thank you very much Sunny

    Plugin Author Sunny Johal

    (@sunny_johal)

    Hi alvaro,
    Here is a small example to point you in the right direction (similar to my function defined above). Lets say you want to add a custom control using php for all paragraphs with the class alvaro (e.g. p.alvaro)

    function my_theme_egf_default_controls( $options ) {
    /**
         * Here is an example of adding our own custom theme
         * controls (the selectors used are arbitrary this
         * would change depending on the css element that
         * you want to control). This makes all paragraphs
         * with the class alvaro black, uppercase, underlined
         * with a font size of 14px and a line height of
         * 1.2
         */
        $options['alvaro_paragraphs'] = array(
            'name'        => 'alvaro_paragraphs',
            'title'       => 'Paragraphs for Alvaro',
            'description' => 'A description for my custom control',
            'properties'  => array( 'selector' => 'p.alvaro' ),
            'default'     => array(
                    'line_height' => 1.2,
                    'font-color'  => '#000000',
                    'text_transform' => 'uppercase'
                    'font_size'   => array( 'amount' => 14, 'unit' => 'px' ),
                    'text_decoration' => 'underline',
            ),
        );
    
        // Return the default controls
        return $options;
    }
    add_filter( 'tt_font_get_option_parameters', 'my_theme_egf_default_controls' );

    Notice the default array. This is where the defaults are being defined.

    The reality is that the level of customization I have coded into this plugin is so broad that I can’t cover it all in a single thread, so support on this issue is going to be quite limited (mainly due to limitations of my free time).

    Have a look at the parse_font_control_array() function in includes\class-egf-register-options.php
    to see exactly what default values you can customize for each font control.

    Cheers

    Sunny

    Great, this is exactly what I was looking for. You are really helpful, Thank you very much for your time.

    In the code you just posted in your last comment ‘text_transform’ => ‘uppercase’ is missing a comma after (for others interested).

    Best,
    Alvaro

    Sunny,
    So I realized in a clean theme/plugin install, the above mention adds the fonts and selected options to the Customizer window. If I open the tab of one of them, the settings I defined are there. In the page the styles are applied correctly to the corresponding selector. However the font doesnt load (I can see this from Chrome developer tools). That is the issue Im having, if I change to some other fontfamily and back to theme predefined and save it works as it should.
    Anything else I should be doing?
    Pd. I also tried adding
    ‘stylesheet_url’ => ‘https://fonts.googleapis.com/css?family=Source+Sans+Pro:600’,
    for example, with no luck
    Thank you

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Integrate EGF with theme?’ is closed to new replies.