Warning: Attempt to read property “ID” on null in
… /wp-content/plugins/content-control/inc/functions/rule-callbacks.php on line 88
Using:
Plugin version 2.2.8
WordPress version: 6.5.3
I have downgraded PHP to go back to normal.
]]>When I submit the form that calls fields directly, it works fine. However, the form that uses do_settings_sections() and callbacks results in a “400 Bad Request” error when submitted.
Why isn’t the do_settings_sections form submitting correctly?
Here’s a simplified version of my code:
function snap_save_settings() {
error_log('triggered snap_save_settings, Success!');
}
add_action('admin_post_snap_save_settings', 'snap_save_settings');
class Snap_Settings extends Snap_Settings_Page {
protected function initialize_settings() {
// General Settings Section
$this->add_section('snap_main_settings', '', [$this, 'main_settings_section_callback'], 'snap-main-settings');
$this->add_field('snap_main_settings', 'snap_linking_mode', '', [$this, 'linking_mode_callback'], 'snap-main-settings');
}
//callback
public function main_settings_section_callback() {
}
public function linking_mode_callback() {
// Output a basic text input form field for testing
echo '<label for="snap_test_input">Test Input:</label>';
echo '<input type="text" id="snap_test_input" name="snap_test_input" value="">';
}
// Display Settings
public function display_settings_page() {
?>
<div class="wrap">
<!-- Form using do_settings_sections() -->
<form method="post" action="<?php echo admin_url('admin-post.php'); ?>">
<label>This form is rendered using do_settings_sections and does not work</label>
<input type="hidden" name="action" value="snap_save_settings">
<?php
settings_fields('snap_settings_group');
do_settings_sections('snap-main-settings');
submit_button();
?>
</form>
<br>
<br>
<!-- Form with fields rendered directly -->
<form method="post" action="<?php echo admin_url('admin-post.php'); ?>">
<label>This form is rendered directly and it works</label>
<input type="hidden" name="action" value="snap_save_settings">
<input type="text" name="snap_test_input" value="Test Value">
<input type="submit" value="Save Changes">
</form>
</div>
<?php
}
}
new Snap_Settings();
Here is the settings base:
abstract class Snap_Settings_Page {
private $sections = [];
abstract protected function initialize_settings();
public function __construct() {
add_action('admin_menu', [$this, 'add_menu_page']);
add_action('admin_init', [$this, 'register_settings']);
}
public function add_menu_page() {
add_options_page(
'Snap Settings', // Page title
'Snap', // Menu title
'manage_options', // Capability
'snap-settings', // Menu slug
[$this, 'display_settings_page'] // Callback function
);
}
public function register_settings() {
$this->initialize_settings();
foreach ($this->sections as $section_id => $section) {
add_settings_section(
$section_id,
$section['title'],
$section['callback'],
$section['page_slug']
);
foreach ($section['fields'] as $field_id => $field) {
add_settings_field(
$field_id,
$field['title'],
$field['callback'],
$field['page_slug'], // Use the page_slug from the field
$section_id
);
register_setting('snap_settings_group', $field_id);
}
}
}
protected function add_section($id, $title, $callback, $page_slug = 'snap-settings') {
$this->sections[$id] = [
'title' => $title,
'callback' => $callback,
'fields' => [],
'page_slug' => $page_slug // Store the page_slug with the section
];
}
protected function add_field($section_id, $field_id, $title, $callback, $page_slug = 'snap-settings') {
if (!isset($this->sections[$section_id])) {
// Optionally handle the error if the section does not exist
return;
}
$this->sections[$section_id]['fields'][$field_id] = [
'title' => $title,
'callback' => $callback,
'page_slug' => $page_slug
];
}
abstract public function display_settings_page();
}
]]>Understand the method for excluding a script when it’s sitting on the server itself, is there a different form for offsite scripts that are performing callbacks such as https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap
In my case for Google Address autocomplete, getting debloat to ignore these:
1) <script type="text/javascript" src="https://myserver.com/wp-content/plugins/fc-google-address-autocomplete/js/google-address-autocomplete-118.min.js" id="fc-gaa-google-address-autocomplete-js"></script>
I believe this is just add the following to the exclusions: wp-content/plugins/fc-google-address-autocomplete/js/google-address-autocomplete-118.min.js
2) <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=myAPIkey&libraries=places&callback=GoogleAddressAutocomplete.init" id="fc-gaa-google-address-api-js"></script>
This is the one I’m having issues with, what should I put into the exclusion box?
I’ve tried just using the ids,
id:fc-gaa-google-address-api-js
id:fc-gaa-google-address-autocomplete-js
but google autocomplete works when debloat JS optimisation is off, and (I’m assuming through my inept use of the exclusions) doesn’t work with debloat’s JS defer optimisation on.
what should I be writing in there?
regards Philip
]]>The payment gateway (Bambora) and logistics partner could receive data (orders) from the WooCommerce website, but when they tried sending back the updated order status, they only got 403 error messages. No callbacks was allowed.
I tried changing the following settings in iThemes Security but it didn’t help:
* Adding all IP numbers used by the payment gateway and logistics partner to Lockout White List
* Changing the WordPress API settings from “Restricted Access” to Default Access
* Disabling Away Mode
Any ideas on what iThemes Security setting that can cause the 403 error messages?
]]>Warning: session_id(): Cannot change session id when session is active in /srv/bindings/6dd16a19c38743349337771a37985223/code/wp-content/plugins/wp-native-php-sessions/callbacks.php on line 34
From another post in the support section my understanding is that other plugins may be initializing the session before this plugin so a mu-plugin needs to be created. After doing this though the issue still persists.
Sessions are used for a couple different reasons on this site in connection with the eCommerce functionality and are required. Any help in either resolving this or helping us figure out if this site will even work on the Pantheon setup would be appreciated!
I can provide needed access information privately.
]]>Something like do_that_magic_search_form(‘my-post-type’, ‘my own callback’);
Is this possible or do I have to invent this wheel again?
]]>almComplete()
, but the problem is that must of the AdServers give a <script> tag and when I do:
<script>
/* <![CDATA[ */
$.fn.almComplete = function(alm){
$('.alm-seo').append('<div class="m-block m-block--grid article"><header class="m-block__header cf"><h6>publicidad<\/h6><\/header><div class="pinnned_wrapper"><div class="m-block__body cf"><figure data-dimensions="300x250" class="lazyload" style="width: 300px;"><script> eplAD4M("970x90_a"); <\/script><\/figure><\/div><\/div>');
};
console.log('Done');
/* ]]> */
</script>
When I clicked LoadMore , the posts aren’t loaded, instead something really odd happened ,
the page load only :
<html><head></head><body><div id="eplAdDiv970x90_a"></div></body></html>
and everything else disappears.
and Cosole Log gave me: alm-seo.min.js?ver=1.5.2:23 Uncaught TypeError: Cannot read property 'top' of undefined
.
Maybe the solution is inside the repeater with php and a $count++
but I don’t know if that can be done .
Thanks
UPDATE
I forgot to tell that if I remove :
<script> eplAD4M("970x90_a"); <\/script>
from the callback , the Div is printed right after all the post are loaded
https://www.ads-software.com/plugins/ajax-load-more/
]]>Does anyone know which callbacks I need to use to do so? Has anyone been able to integrate this?
https://www.ads-software.com/plugins/ninja-forms/
]]>