When mapping shortcodes using vc_map, you can assign icons to your new Visual Composer element.
If you created a container element, that wraps around other elements, the child element icon will currently be overwritten with the parent icon. A fix is apparently on its way :)
Currently the only way is to skip the icon option completely and use pure CSS for that.
You can enqueue a CSSs file for the admin through a vc_map option „admin_enqueue_css„.
1 2 3 4 5 6 7 8 9 10 |
.wpb_vc_your_element > .wpb_element_wrapper > .wpb_element_title i, #vc_your_element i.vc_element-icon { background-position: 0 0; background-image: url(/path_to_images/vc_your_element.png)!important; -webkit-background-size: contain; -moz-background-size: contain; -ms-background-size: contain; -o-background-size: contain; background-size: contain; } |
The CSS targets the icon of the displayed element in the editor and the icon when adding new elements to the layout.
This video should give you a good idea what the addon can actually do.
In my last article I gave you a rough overview of the features & requirements. Here some more details and additions:
The addon is mostly done. I am finalizing the main admin area this week and will do a final cleanup next week, for the first beta release.
Many people have asked me for a release date. I currently plan to have a fully working Beta in the next 2-3 weeks. Will offer the Addon to a small closed group of customers first, before I think about other release options. I think I will offer between 20-30 slots for the beta run. If you are interested let me know.
Regards
Alexander
Update: Video Preview
I am still busy finalizing the Fullpage.js Addon for Visual Composer. Hope to have some more images or even a video next week :)
Some requirements for the Visual Composer Addon:
The Addon will ease Fullpage.js integration immensely, but for a more advanced integration some CSS / JavaScript knowledge will always be needed. Do checkout the main Fullpage.js documentation for more information.
Many people have asked me for a release date. I currently plan to have a fully working Beta in the next 2-3 weeks. Will offer the Addon to a small closed group of customers first, before I think about other release options. I think I will offer between 20-30 slots for the beta run. If you are interested let me know.
WordPress is fun, but many of my clients take the plugin fun to new levels :)
Depending on how well plugins / shortcodes have been integrated, linked JavaScript & CSS files can clutter up your pages really fast.
The problem is that many plugins do not load external files on demand. Same applies for WebFonts that have been added to the system.
Its no fun hunting down all those resources and slim down pages manually, but sometimes there is no way around it.
In WordPress CSS & JavaScript files are enqueued by plugins / themes.
1 2 3 4 5 6 7 |
wp_enqueue_style( 'my-extension', get_template_directory_uri() . '/css/my-extension.css', array( 'bootstrap' ),// an array of dependent styles '1.2', // version number 'screen', // CSS media type ); |
1 2 3 4 5 6 |
wp_enqueue_script( 'my-extension-script', get_template_directory_uri() . '/js/my-extension.js', array(), // Scripts your extension depends on '1.0.0', true // Place in footer ); |
To remove files from pages you need to unregister (CSS / JavaScript) those files using their specific handle. This also allows you to replace a specific file with your own version.
1 2 3 |
wp_deregister_style( 'my-extension' ); wp_deregister_script( 'my-extension-script' ); |
The big problem is finding the names of the enqueued files, their handles. They are often hidden deep in the plugins. But if they are registered somewhere, you should be able to find them somewhere :)
1 2 |
global $wp_styles; print_r($wp_styles); |
Add this to your functions.php and you will get a nice overview of all the styles and their handles registered. You can do the same for the registered scripts.
1 2 |
global $wp_scripts; print_r($wp_scripts) |
This will get you an overview of all the registered files. Now its only a matter of doing the unregister operation with some simple WordPress conditional logic.
1 2 3 4 5 6 |
add_action( 'some-extension', 'some_mextension', 100 ); function my_extension() { if ( !is_page('Home') ) { wp_deregister_script( 'some-extension' ); } } |
Yes there is and it is called „Asset Queue Manager“ …
„This tool allows you to monitor, dequeue and requeue scripts and styles that are enqueued on your site. It is designed for frontend performance engineers who want to view and manage all assets enqueued on any page and control the minification and concatenation themselves.“
Messing with styles can be ugly, but often wont break things completely. Messing with JavaScript includes can cripple a setup badly. So you should be really sure which scripts / styles can be deactivated on specific pages. Please do not experiment on a live website … I warned you ! :)
Many developers hesitate to call WordPress a PHP development platform. I know what I am talking about, as I developed a platform of my own. PHP platforms normally only provide a skeleton and we need to
With WordPress you get most of this out-of-the-box, with some predefined structures.
Having a flexible administration backend in place makes it easy to concentrate on the things that matter for a project, which is designing a frontend experience.
And especially with the JSON REST API finding its way into the core slowly, you are completely free when it comes to using the stored data in your frontend designs.
Sure that was possible before, just with some more work on our side ;)
But WordPress embracing the „freeing of data“ through JSON, shows us where the ride is going.
There has not been a single project of mine in the past year, that has not used the REST API in some way. And all of this fits perfectly into the new single page app universe.
WordPress interfaces with your javascript framework setup (client side templating, DOM manipulation, data binding, routing …) and frees you from any design handcuffs.
It has become much easier and faster over the past 2 years to say „YES“ to many of my clients wishes.
Its nice to finally see data flow from the server to the client and back that easily.
If you are not exited about this … I am :)
In a current project I am using pages as templates, to load content into specific containers on the website. The website will be using up to 15 different languages.
The main language setup is done through WPML, which creates linked content per language. This helps, as some languages will fail terribly when translating them through a pure gettext setup, as the words setup is often completely different.
But there is always static stuff that can be translated directly through the language files. For that I use a simple shortcode that allows me to keep the native language as a basis in all linked content. Easier to move around, as I can actually read and understand it :)
Call the shortcode from the functions.php
1 |
add_shortcode('quick_trans','do_quick_trans'); |
The shortcode function itself. This loads the language textdomain from the specified location and translates the string.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function do_quick_trans($atts, $content) { extract(shortcode_atts(array( 'location' => 'PATH_TO_LANG_FILE', 'lang' => 'LANG_TO_USE', 'textdomain' => 'TEXTDOMAIN' ), $atts)); load_textdomain($textdomain, $location.$lang.'.mo'); $content = __($content, $textdomain); return $content; } |
How to use it in your post or page content
1 2 3 4 5 6 7 8 |
German [quick_trans lang="de_DE"]Simple is nice![/quick_trans] Spanish [quick_trans lang="es_ES"]Simple is nice![/quick_trans] Spanish - Latin America / with a special path for the lang file location [quick_trans lang="es_LA" location="/wp-content/..."]Simple is nice![/quick_trans] |
Conditional Tags are a powerful thing in WordPress and especially handy to show or hide things.
„The Conditional Tags can be used in your Template files to change what content is displayed and how that content is displayed on a particular page depending on what conditions that page matches. “
Two plugins are part of my essentials, that utilize the Conditional Tags:
You can easily define your own Conditional Tags in your functions.php or plugin.
„NextGEN Facebook (NGFB) gives you total control over the information social website crawlers need, improving Google Search ranking, social engagement, and click-through-rates on Facebook, Google+, Twitter, Pinterest, LinkedIn, StumbleUpon, Tumblr and and many more“
A powerful plugin for WordPress, but it sometimes displays many image dimension errors. Even if those errors remind me to optimize the page or post, I sometimes prefer to ignore these during development :)
Here a simple way to hide them:
1 2 3 4 5 6 7 |
add_action('admin_head', 'hide_ngfb_errors'); function hide_ngfb_errors(){ echo '<style type="text/css"> [id^="err_err_wp"]{display: none} </style>'; } |
Adding Metaboxes in WordPress to your admin areas normally involves 3 steps:
This can be done much easier using Custom Metaboxes and Fields for WordPress, which is a metabox, custom fields and forms library. The library provides a bunch of custom fields and also allows you to add your own easily. Much easier to build new Metaboxes fast!
List of field types included:
Simple example from the CMB2 Github page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
if ( file_exists( __DIR__ . '/cmb2/init.php' ) ) { require_once __DIR__ . '/cmb2/init.php'; } elseif ( file_exists( __DIR__ . '/CMB2/init.php' ) ) { require_once __DIR__ . '/CMB2/init.php'; } add_action( 'cmb2_init', 'cmb2_sample_metaboxes' ); /** * Define the metabox and field configurations. */ function cmb2_sample_metaboxes() { // Start with an underscore to hide fields from custom fields list $prefix = '_yourprefix_'; /** * Initiate the metabox */ $cmb = new_cmb2_box( array( 'id' => 'test_metabox', 'title' => __( 'Test Metabox', 'cmb2' ), 'object_types' => array( 'page', ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left // 'cmb_styles' => false, // false to disable the CMB stylesheet // 'closed' => true, // Keep the metabox closed by default ) ); // Regular text field $cmb->add_field( array( 'name' => __( 'Test Text', 'cmb2' ), 'desc' => __( 'field description (optional)', 'cmb2' ), 'id' => $prefix . 'text', 'type' => 'text', 'show_on_cb' => 'cmb2_hide_if_no_cats', // function should return a bool value // 'sanitization_cb' => 'my_custom_sanitization', // custom sanitization callback parameter // 'escape_cb' => 'my_custom_escaping', // custom escaping callback parameter // 'on_front' => false, // Optionally designate a field to wp-admin only // 'repeatable' => true, ) ); } |
The current Google Analytics Dashboard for WordPress integrates no Opt-Out to disable tracking, which is required in Europe. Here is a workaround for that.
Paste this into your theme function.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
if ( !is_user_logged_in() && class_exists('GADWP_Manager') ) { add_action('wp_head', 'ga_optout_script', 1); } function ga_optout_script(){ // Read GA Dashboard Settings $options = (array) json_decode(get_option('gadash_options')); // Get GA Dashboard profiles foreach($options['ga_dash_profile_list'] as $profile){ $ga_ua_profile[$profile[1]] = $profile[2]; } // Get active Analytics profile for the current website $active = $options['ga_dash_tableid_jail']; $activeUA = $ga_ua_profile[$active]; // Add opt-out script + active UA echo "<script> var gaProperty = '".$activeUA."'; var disableStr = 'ga-disable-' + gaProperty; if (document.cookie.indexOf(disableStr + '=true') > -1) { window[disableStr] = true; } function gaOptout() { document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/'; window[disableStr] = true; } </script>"; } |
Then add this to your data privacy document:
1 |
<a href="javascript:gaOptout()">Disable Google Analytics tracking</a> |