I just separated my functions.php file into smaller files and the required each of those inside functions.php
One of those files is 'dashboard.php' where I add a widget to change a notice in my shop.
<?php
// Store Notice Dashboard Widget
add_action('wp_dashboard_setup', 'widgets_definitions');
function widgets_definitions() {
error_log("widget_defs");
wp_add_dashboard_widget(
'update_store_notice_widget', // widget slug
'Update Store Notice', // Title
'render_store_notice_widget', // Display function
'handle_store_notice_widget' // Handle configure function
);
error_log("widget_defs 2");
}
function render_store_notice_widget() {
error_log("render");
$notice_text = get_option('woocommerce_demo_store_notice');
error_log($notice_text);
if (!isset($notice_text)) {
$notice_text = "";
}
echo "<p><strong>Current Store Notice:</strong></p>";
echo "<p>" . $notice_text . "</p>";
}
function handle_store_notice_widget() {
error_log("handler");
$notice_text = get_option('woocommerce_demo_store_notice');
if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['woocommerce_demo_store_notice'])) {
error_log("POST");
//minor validation
$notice_text = wp_kses($_POST['woocommerce_demo_store_notice']);
error_log($notice_text);
//save update
update_option('woocommerce_demo_store_notice', $notice_text);
}
if (!isset($notice_text)) {
$notice_text = "";
}
error_log($notice_text);
echo "<p><strong>New Store Notice</strong></p>";
echo "<textarea name='woocommerce_demo_store_notice'>" . $notice_text . "</textarea>";
}
?>
For some reason it just doesn't show up in my dashboard, no errors.
I added error_log() before and after the require and at the end of the 'functions.php' file and I can see all 3 of them in the log file, but none of the ones on 'dashboard.php'.
Any idea what's going on?
Edit
<?php
add_action('wp_enqueue_scripts', 'supro_child_enqueue_scripts', 20);
function supro_child_enqueue_scripts() {
wp_enqueue_style('supro-child-style', get_stylesheet_uri());
if (is_rtl()) {
wp_enqueue_style('supro-rtl', get_template_directory_uri() . '/rtl.css', array(), '20180727');
}
}
require "includes/dashboard.php";
require 'file';
require 'file';
require 'file';
[...]
That's my functions.php file, the only thing omitted are all the other requires.
I'll change that to wp_kses_post(), thanks. @DaveRomsey
wp_kses()
towp_kses_post()
or add the missing parameters towp_kses()
to avoid an error when saving.php <?php add_action('wp_enqueue_scripts', 'supro_child_enqueue_scripts', 20); function supro_child_enqueue_scripts() { wp_enqueue_style('supro-child-style', get_stylesheet_uri()); if (is_rtl()) { wp_enqueue_style('supro-rtl', get_template_directory_uri() . '/rtl.css', array(), '20180727'); } } require "includes/dashboard.php"; require 'file'; require 'file'; require 'file'; [...]
That's my functions.php file, the only thing omitted are all the other requires. I'll change that to wp_kses_post(), thanks.