I am using a paid theme which is using Redux Framework. I am trying to add a new field in Footer Options. I am able to add this field in options but only in print_r() function it is showing not showing in Themes Options Panel.
function add_another_section_bl($sections){
$sections[12]['fields'][] = array(
'id' => 'rd_footer_message_1',
'type' => 'textarea',
'title' => __('Text 2 to display in footer under bar', 'thefoxwp'),
'subtitle' => __('write your copyright information or anything you\'d like.', 'thefoxwp'),
'validate' => 'html', //see http://codex.wordpress.org/Function_Reference/wp_kses_post
'default' => 'Copyright 2015 Tranmautritam\'s team | All Rights Reserved'
);
return $sections;}
add_filter("redux/options/rd_data/register", 'add_another_section_bl');
In array data it is showing the required data but not in Options Panel in wordpress dashboard.
Kindly get me out of this.
There's a much simpler approach if you use the Redux API:
https://docs.redux.io/configuration/redux-api.html
You can modify, add, update any section or field before it is rendered. Please note, you may have to put your code within hooks. Also please note the Redux 4 method names have changed from setArgs to set_args (camelcase to non).
Otherwise, you will have all you need.
Related
I need to add attribute "rel" to vc_btn.
When i add to functions.php
$attributes = array(
'type' => 'textfield',
'heading' => "rel nofollow",
'param_name' => 'element_rel',
'value' => '',
'description' => 'Add nofollow?'
);
vc_add_param( 'vc_btn', $attributes );
It shows when i edit button (backend).
But nothing happens on page (front). vc_btn is loaded as one of the elements by Grid Post.
I have tried to copy vc_btn.php from /include/templates/shortcodes/ to created dir /vc_templates/ in theme directory.
I have tried this, but nothing:
How do I add an HTML attribute to row (WP Bakery Visual Composer)?
Problem is that when Grid Post load content it is not using vc_btn.phg from /include/templates/shortcodes/vc_btn.php
(or my_theme/vc_templates/vc_btn.php )
but from
/include/templates/params/vc_grid_item/attributes/vc_btn.php
Thans for any help
I am not sure if you still need this. but this answer might help someone looking for customizing vc_btn link, class, attribute etc.
Please use the filter vc_gitem_post_data_get_link_real_rel to add attribute "rel" to vc_btn. more filters are available like :
vc_gitem_post_data_get_link_link,
vc_gitem_post_data_get_link_target,
vc_gitem_post_data_get_link_title
more detail can be found in the plugin file js_composer/include/autoload/params/vc_grid_item.php and function name vc_gitem_create_link_real at line 100
Hope, someone will love it.
Is there a straightforward way to fully customize the backend WP admin (top) bar? I want to replicate the frontend nav with logo/styling and a few links. I've googled this to no end and haven't found any clear cut way to "create your own" admin bar (avoiding plugins).
My customers access all of their paid content on the backend of WP, so I'd like to mimic the branding/logo/style/links of the frontend. Thank you to any helpful answers/resources!
You can use the admin_bar_menu action to customize the default admin bar by removing/modifying existing menus and adding new ones. You can also add sub-menus too.
It would take a bit of work to completely overhaul it, but here is the basic syntax for creating and adding menus to it (place in functions.php or equivalent):
add_action('admin_bar_menu', 'nebula_admin_bar_menus', 800);
function nebula_admin_bar_menus($wp_admin_bar){
$wp_admin_bar->add_node(array(
'id' => 'nebula-github',
'title' => 'Nebula Github',
'href' => 'https://github.com/chrisblakley/Nebula',
'meta' => array('target' => '_blank')
));
$wp_admin_bar->add_node(array(
'parent' => 'nebula-github',
'id' => 'nebula-github-issues',
'title' => 'Issues',
'href' => 'https://github.com/chrisblakley/Nebula/issues',
'meta' => array('onclick' => 'exampleFunction(); return false;') //JavaScript function trigger just as an example.
));
}
This method could be done in a loop to mimic your frontend nav. HTML can be included in this and styles can also be applied to the elements as needed. You can even run JavaScript functions on click events if you wanted to (example in snippet above).
I hope this is in the ballpark of what you're looking to do, or at least gets you headed in the right direction.
I have a block which displays list of RSS feed from an external site. I want to keep caching other blocks except the mentioned block. Howto do that?
For example, I have blockA, blockB and blockC. I only want to change the blockB's cache settings permamently to DRUPAL_NO_CACHE and leave other blocks as they are and I want to do that programmatically.
You can change the caching roles in the specific module that creates youre block.
In the block info like beneath:
function pref_block_info() {
return array(
'pref_main' => array(
'info' => t('Display flash game for auth. users'),
'cache' => DRUPAL_NO_CACHE,
),
'pref_winner' => array(
'info' => t('Show the winner of the last week.'),
'cache' => DRUPAL_NO_CACHE,
),
'pref_leader' => array(
'info' => t('Show the leader of the current week.'),
'cache' => DRUPAL_NO_CACHE,
),
'pref_top' => array(
'info' => t('Show the top 10 of the current week.'),
'cache' => DRUPAL_NO_CACHE,
),
);
}
The answer given by Jurgo is perfectly right, if you are defining the block within your own module.
In case if you want to change the caching behavior of a block written by some other module then you can use the function mymodule_block_list_alter
function mymodule_block_list_alter(&$blocks, $theme, $code_blocks) {
// Remove the caching on rss feeds block.
// Here rss-feeds is the unique key for the block
$blocks['rss-feeds']['cache'] = DRUPAL_NO_CACHE;
}
Where do the blocks come from? That's important. As Jurgo said, you can specify it in hook_block_info if it's a custom module. If they are views blocks, there is a caching setting per display within views that handles this. If they are blocks provided by some other module, you'd need to directly query the database to change the block's caching setting.
As a general note, to display RSS feeds, just use Feeds and Views. Then you don't write custom code at all for any of this.
This will reduce the work by going to performance settings page (admin/settings/performance) & clicking "cleared cached data" by scrolling down.
But make sure that this page is only accessed by administrator.
For Drupal 7 is same as Drupal 6:
<?php
drupal_flush_all_caches();
drupal_set_message('cache flushed.');
?>
I want to use autocomplete-fields that link to an external source for their autocomplete-data. Drupal seems to refuse all autocomplete_paths that are not reachable within Drupal. Any ideas how to circumvent that problem? The form field looks like that:
$form['business_city'] = array(
'#type' => 'textfield',
'#size' => 30,
'#title' => t('city'),
'#autocomplete_path' => '_/city?=',
'#default_value' => $userProfile->field_address_business_city[0]['value'],
);
_/city is not reachable within Drupal for performance reasons. The script bootstraps Drupal up to session-level to check for a valid login.
UPDATE:
If I create an autcomplete-field by attaching the needed markup manually to the field it works but it is awkward to maintain:
'#attributes' => array('class' => 'form-autocomplete'),
'#suffix' => '<input type="hidden" disabled="disabled" value="/_/city?n=" id="edit-private-city-autocomplete" class="autocomplete">',
Instead of hacking, you could make sure that the path you are querying "/_/city?n=" is a valid menu_hook item. That way it will validate against the drupal_valid_path() inside theme_textfield(). From within the menu hook function callback you could then forward the request to your external data source.
Drupal 6 validates in theme_textfield() if the autocomplete path is a valid (internal) path.
So, you can't work around this unless you override that theme function.
I am a bit newbie in Drupal theming and I can't get one detail in Forum modules theming.
forum.module file contains forum_theme function that controls how this module is themed
and has this line
function forum_theme() {
......
'forum_list' => array(
'template' => 'forum-list',
'arguments' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
),
I also see forum-list.tpl.php file in forum directory, so I start to wonder when this file is called and where it gets data from, but all I can find in forum.module is this function.
function template_preprocess_forum_list(&$variables)
Am I missing something? So in general my question is who and when invokes custom registered theme function, like forum_list
Simple answer is if you in your theme directory put mytheme-forum-list.tpl.php (where mytheme is the name of your theme) and customise it drupal should pick it up (clear the cache first).
This line in template_preprocess_forum calls the Drupal theme function
$variables['forums'] = theme('forum_list',
$variables['forums'],
$variables['parents'],
$variables['tid']);
This will reference the line in forum_theme()
'forum_list' => array(
'template' => 'forum-list',
'arguments' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
),
Which tells the templating enging to look for forum-list.php and provides arguments.
If you install the devel module and turn on the theme developer module. This will show you all of the candidate templates and functions which Drupal will look for when rendering content.
In general (but with specific exceptions) Drupal looks for the best match template and falls back to the pre defined functions.
if there is nothing that matches. Have a look at the theme guide and in specific the section on Overriding themable output you may also find hook_theme of interest.