id = 0; $result->module = $name; $result->params = ''; if (isset($wp_widget_factory->widgets[$classname])) { // get settings of all the widgets of this type $settings = $wp_widget_factory->widgets[$classname]->get_settings(); if ($settings) { // take only the first one $result->id = key($settings); $result->params = reset($settings); // JSON encode params for Joomla compatibility $result->params = json_encode($result->params); } } /** * If we are not able to find a widget, then we should look into the * posts and pages in search of a Gutenberg block and extract the * settings from there. * * @since 10.1.52 */ if (!$result->id) { // split the module name in chunks: // [MOD] | [COMPONENT] | ... $block = explode('_', $name); // construct gutenberg block identifier $block = $block[1] . '/' . implode('-', array_slice($block, 2)) . '-widget-block'; // look for a post/page that contains the block name of the requested module $query = new WP_Query([ 's' => '/", $post->post_content, $match)) { // keep the parameters encoded in JSON format for Joomla compatibility $result->params = $match[1]; } } } return $result; } }