WordPress theme behaving bad - php

Hope you all are doing great since last few days i am facing an issue with my WordPress site this is a plugin or theme i am not sure but the file is in theme which throws error of undefined function
because of this error i am not able to open my customize menu from wordpress admin panel
and once i commented the code line where this code exists it start working but widgets does not work properly like if i enable social icons in widgets i wont be able to disable them and save settings here is the code i have commented.
$jobcareer_opt_array = array(
'name' => esc_html__('Title', 'jobcareer'),
'desc' => '',
'hint_text' => '',
'echo' => true,
'field_params' => array(
'std' => esc_attr($jobcareer_widget_title),
/*'id' => cs_allow_special_char($this-
>get_field_id('title')),*/
'classes' => '',
/*'cust_id' => cs_allow_special_char($this-
>get_field_name('title')),*/
/*'cust_name' => cs_allow_special_char($this-
>get_field_name('title')),*/
'return' => true,
'required' => false
),
);

May be there is some version conflict between the theme and Codestar plugin. You can ask your theme's developer for that. Or as a temporary solution just remove cs_allow_special_char function and use its parameter insteaad. For example replace
cs_allow_special_char($this->get_field_name('title'))
with
$this->get_field_name('title')
and it should work then.
I checked the plugin's source, that function doesn't do any critical operation:
function cs_allow_special_char($input = ''){
$output = $input;
return $output;
}

Related

Wordpress Customizer keeps hiding custom sections

I have custom plugin that adds Customizer sections and options.
The sections can be seen briefly on the customizer screen but then disappear. This behavior is happening on all themes (I am using my plugin on other sites).
Maybe it might be because the setting fields are not used in the theme yet, but even if I create my own theme (for which this plugin is mainly used) and add echo get_theme_mod('setting-key') somewhere in the themes code, the sections are still being hidden by wordpress.
I have clean Wordpress install version 5.2.2, using default Twenty Nineteen theme with only jQuery updater plugin active. I have checked all JS code for potential errors and any hiding happening, but nothing on my part can be causing this.
This is how I am adding sections, in customize_register hook:
add_action('customize_register', 'setup_section');
function setup_section($wp_customize){
// Add section
$wp_customize->add_section('section_id', array(
'title' => 'Section Title',
'priority' => 160,
));
// Add settings for a field
$wp_customize->add_setting('setting_id', array(
'default' => '',
'transport' => 'refresh',
));
// Add the field into a section and assign setting id
$wp_customize->add_control('setting_id', array(
'label' => 'Option Label',
'section' => 'section_id',
'settings' => 'setting_id',
'type' => 'text',
));
}
The PHP code is working as expected, but after the page loads, all my custom sections get display: none; inline css added and the sections disappear.
Any help is appreciated.
Another reason why the custom sections kept hidden is when they don't have any controls. When a section is empty WordPress hides it by default.
Here's a full working piece of code for adding a section within Customizer with one control:
function mytheme_customize_register( $wp_customize ) {
$wp_customize->add_section('footer_settings_section', array(
'title' => 'Footer Text Section'
));
$wp_customize->add_setting('text_setting', array(
'default' => 'Default Text For Footer Section',
));
$wp_customize->add_control('text_setting', array(
'label' => 'Footer Text Here',
'section' => 'footer_settings_section',
'type' => 'textarea',
));
}
add_action( 'customize_register', 'mytheme_customize_register' );

DRUPAL-7: hook declaration missing

Goodmorning everyone,
I'm new in Drupal.
I hope don't ask a stupid question.
I'm working with Drupal 7 and I need to edit a custom module for my company developed by another developer.
This is a piece of code where I use "theme" function.
This code is under "sites/all/modules/gestione_attivita_attivita/gestione_attivita_attivita.module"
function gestione_attivita_attivita_block_search_attivita($tipo_ricerca) {
$block['subject'] = "";
$ricerca = gestione_attivita_ricerca_fetchAll($tipo_ricerca);
$block['content'] = theme('ricerca_attivita', array(
'items' => $ricerca,
'tipo_ricerca' => $tipo_ricerca
));
return $block;
}
I know that should exist "ricerca_attivita" hook declared somehere in my files.
I'v been looking for something like "['ricerca_attivita'] = array(" or similar words or sub-words in all my files of my site folder but it doesn't exist.
The only thing I know is that under :"sites/all/themes/customModuleOfmyCompany/templates" there are several tpl files and in particular one called "ricerca_attivita.tpl.php" that work and receives data from theme function but I don't know how this is possible.
I don't know who tell to theme call to go on another folder on another path and use "ricerca_attivita.tpl.php" and not foo.tpl.php for example.
Is there anyone that can help me?
Another thing:
Going under includes/theme.inc and debugginng it I have this printing hook info:
array (
'template' => 'ricerca_attivita',
'path' => 'sites/all/themes/customtheme/templates',
'type' => 'theme_engine',
'theme path' => 'sites/all/themes/customtheme',
'preprocess functions' =>
array (
0 => 'template_preprocess',
1 => 'contextual_preprocess',
),
'process functions' =>
array (
0 => 'template_process',
1 => 'ctools_process',
2 => 'rdf_process',
),
)
but I don't know who is that declare it
I think you should use the developer module for themers https://www.drupal.org/project/devel_themer
And about theming function, did you search for this function inside the themes folder?
Hope that helps.

How can I put in a proper image path URL for radio button options in my Wordpress Child Theme Customizer?

I've been working on this for a while and even though i've searched through a lot of stackoverflow questions/answers, i haven't been able to find what i'm looking for.
My question:
I'm working on developing my first genesis wordpress child theme, particularly now the customizer. I want the user to be able to have different options, one of which is choosing from a few background patterns that I've designed for a certain div class. There are three different patterns, and I've been able to so far make three radio buttons. Here is the code:
$wp_customize->add_setting('BG_Pattern', array( 'default' => '#f5ebdf',));
$wp_customize->add_control('BG_Pattern', array(
'label' => __('Background Pattern', 'FoxiePro'),
'section' => 'backgrounds',
'settings' => 'BG_Pattern',
'type' => 'radio',
'choices' => array(
'tan.jpg' => 'Tan',
'#e6e6e6' => 'gray',
'teal' => 'teal',
),
));
And the output is this, in the header.php file:
<?php
$BG_Pattern = get_theme_mod('BG_Pattern');
?>
<style>
.enews-widget {background-image: url( '<?php echo $BG_Pattern; ?>' );}
</style>
Where it says "tan.jpg", is where I would like to put in a url to tan.jpg src, which is in my child theme folder. However, any link I put in doesn't make the pattern appear. Inputting something like:
'bloginfo('template_url'); ?>/images/tan.jpg' => 'Tan',
also hasn't worked for me. Anyone have any ideas? Thanks!
Figured it out, because it's a child theme, needed to use the following:
get_stylesheet_directory_uri() . '/images/backgrounds/tan.jpg' => 'Tan',

The parameter ‘path’ is required. in my functions.php file

Hi guys so I have been working on my functions.php page for a custom Wordpress theme of mine and can't figure out the issue... It is something between lines 0 - 10... Some things I have read relate it to the get_stylesheet_uri() Please help... I am only new to Wordpress and can't figure this out...
<?php
function asns_resources() {
wp_enqueue_style('style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'asns_resources');
//Custom Appearance
function allsugar_customise_register( $wp_customize ){
$wp_customize->add_setting('asns_link_colour', array(
'default' => '#f4f4f8',
'transport' => 'refresh',
));
$wp_customize->add_section('asns_standard_colours', array(
'title' => __('Standard Colours', 'AllSugar-NoSpice'),
'priority' => 30,
));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'asns_link_colour_control', array(
'label' => __('Link Colour', 'AllSugar-NoSpice'),
'section' => 'asns_standard_colours',
'settings' => 'asns_link_colour',
) ) );
}
add_action('customize_register', 'allsugar_customise_register');
?>
I have experienced that before. Only it was when editing via the cPanel File Manager.
I found the cause of the problem was that I had changed the name of the file/folder after I had already opened the file to edit it.
All I had to do was copy the contents of the file to the clipboard then close the tab in the browser and just re-access that same file again and then paste the code with all the changes I had made before and VOILA!! It successfully saved and "The parameter ‘path’ is required" error was gone.

Drupal 7 Form API - Custom Select Theme

I have been searching all day but unable to find any answers - I am sure I am doing it right as worked fine in Drupal 6 and should work fine in Drupal 7.
I want to give a custom theme function to my select element in my form
$form['field_name'] = array(
'#type' => 'select',
'#title' => t('Title Here'),
'#theme' => 'custom_select',
'#options' => $values,
);
I have the theme hook right to declare the new custom theme function but my problem is when using that custom theme function as above I get an empty $variables array which just reads
Array([element] => null)
can anyone see what I may be doing wrong? cleared cache, done everything I can think of - any ideas why Drupal is not passing the element data to the theme function? thanks
well finally figured this one out incase any one else has the problem - make sure you set render element in hook_theme and not variables!
before
function hook_theme(){
return array(
'select_currency' => array(
'variables' => array('element' => null),
'file' => 'module_name.theme.inc',
));
}
after
function hook_theme(){
return array(
'select_currency' => array(
'render element' => 'element',
'file' => 'module_name.theme.inc',
));
}
I was pulling my hair out until I remembered the render element!

Categories