I am adding my plugin with the yandex.metrica code to the site. The code was applied to the entire site and to the main page.
After that, the ability to create and edit courses disappears.
The code in the plugin:
<?php
/*
Plugin Name: My plugin of yandex
Plugin URI:
Description:
Version: 1.0
Author: vitvlad
Author URI:
*/
?>
?<?php
add_action( 'wp_footer', 'bashka_meta', 10, 2);
function bashka_meta() {
if( is_front_page() ) {
? ? ?>
<meta name="yandex-verification" content="111111111111111"* />
? ? <?php
}
}
*The number has been replaced
An error notification appears:Error Something Went Wrong!
]]>I’m developing a custom numerology calculation tool for my site, Density Matrix Chart, and need some assistance with the following:
The tool is already functional on my site, but I’m encountering challenges with optimization and user experience. Any insights or recommendations would be greatly appreciated!
Thank you!
Kerla Welsion
I built a custom plugin block last month to help our UK customers pick from 33 different subscription options easily.
The plugin and block were working *ok* when I simply added it into the files through ftp access. the block editor screen was not working when opening or saving the page that had the new block on it.
Then it got a little worse today, I built the plugin into the repository, updated and installed with composer. The plugin is visible and activated on the plugins page, but the block itself is not visible to add to the page any longer.
I have looked through the debug.log file and only found complaints about namespacing, which I have now fixed. The block, however, is still not available to add to the page in the editor.
The plugin was built using the @wordpress/create-block package and primarily built with react.
Does anybody have any tips to point me in the right direction?
When I export and import a site, use the “find and replace” function in AI1WPM and export to a file. I then upload using the same plugin on the other site. I notice that my custom plugin’s directory structure changes on import. Instead of my plugin directories and files being overwritten with the new directories and files, my directories are being merged. The files with with the same name are properly overwritten with the new file, but all other directories and files are combined.
Why is Local OR AI1WPM merging these files, as opposed to overwriting/replacing my custom plugin’s files/directories?
]]>Here is my Folder structure
In my index.php file
<?php
/*
Plugin Name: Custom API Plugin
Plugin URI: https://example.com
Description: Enhance the functionality of your WordPress site with the Plugin, a powerful and customizable REST API solution.
Version: 2.5
Author: Mike
Author URI: https://wa.me/2349xxxxxx
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
// Include the main plugin class
require_once plugin_dir_path(__FILE__) . 'includes/class-custom-plugin.php';
// Instantiate the plugin class
$pxm_api_plugin = new PxmAPI();
**In my class-custom-plugin.php file**
<?php
class PxmAPI {
private $namespace = 'v1';
public function __construct() {
add_action('rest_api_init', [$this, 'register_endpoints']);
}
public function register_endpoints() {
// Include endpoint files
require_once plugin_dir_path(__FILE__) . 'endpoints/user-info.php';
require_once plugin_dir_path(__FILE__) . 'endpoints/bank-info.php';
require_once plugin_dir_path(__FILE__) . 'products/test.php';
}
}
In the includes/endpoints/user-info.php file
<?php
// Check if accessed directly
if (!defined('ABSPATH')) {
exit;
}
class UserInfoEndpoints {
private $namespace = 'v1';
public function __construct() {
add_action('rest_api_init', [$this, 'register_endpoints']);
}
public function register_endpoints() {
// User account details route
register_rest_route($this->namespace, '/user', [
'methods' => 'GET',
'callback' => [$this, 'get_userinfo'],
'permission_callback' => [$this, 'check_permissions'],
]);
}
public function get_userinfo(WP_REST_Request $request) {
if (is_user_logged_in()) {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$firstname = $current_user->first_name;
$lastname = $current_user->last_name;
$user_email = $current_user->user_email;
$role = $current_user->roles[0];
$data = [
'basic' => [
'firstname' => $firstname,
'lastname' => $lastname,
'email' => $user_email,
'package' => $role,
],
];
return $data;
} else {
return new WP_Error('unauthorized', 'Invalid Credentials', ['status' => 401]);
}
}
// General User permission
public function check_permissions() {
return current_user_can('read');
}
}
// Instantiate the class when the file is included
$user_info_endpoints = new UserInfoEndpoints();
In my class-custom-plugin.php file
<?php
class PxmAPI {
private $namespace = 'v1';
public function __construct() {
add_action('rest_api_init', [$this, 'register_endpoints']);
}
public function register_endpoints() {
// Include endpoint files
require_once plugin_dir_path(__FILE__) . 'endpoints/user-info.php';
}
}
In the bank-info.php
<?php
// Check if accessed directly
if (!defined('ABSPATH')) {
exit;
}
class BankInfoEndpoints {
private $namespace = 'v1';
public function __construct() {
add_action('rest_api_init', [$this, 'register_endpoints']);
}
public function register_endpoints() {
// Get user information based on the meta key 'kuda_account'
register_rest_route($this->namespace, '/mybank/', [
'methods' => 'GET',
'callback' => [$this, 'get_user_bybank'],
'args' => [
'id' => [
'validate_callback' => function ($param, $request, $key) {
return is_numeric($param);
},
],
],
]);
}
public function get_user_bybank($data) {
$bank_account = absint($data['id']);
// Check if user exists
$user = get_user_by_meta_data('bank_account', $bank_account);
if (!$user) {
wp_send_json_error(array('message' => 'User not found'), 404);
}
$user_data = array(
'firstname' => $user->first_name,
'lastname' => $user->last_name,
'email' => $user->user_email,
);
wp_send_json_success($user_data);
}
// Custom function to get a user by meta data
function get_user_by_meta_data($meta_key, $meta_value) {
// Query for users based on the meta data
$user_query = new WP_User_Query(
array(
'meta_key' => $meta_key,
'meta_value' => $meta_value,
)
);
// Get the results from the query, returning the first user
$users = $user_query->get_results();
return $users ? $users[0] : null;
}
}
// Instantiate the class when the file is included
$bank_info_endpoints = new BankInfoEndpoints();
In the test.php
<?php
// Check if accessed directly
if (!defined('ABSPATH')) {
exit;
}
class TestEndpoints {
private $namespace = 'v1';
public function __construct() {
add_action('rest_api_init', [$this, 'register_endpoints']);
}
public function register_endpoints() {
// Register endpoint for retrieving test posts
register_rest_route($this->namespace, '/test-product', [
'methods' => 'GET',
'callback' => [$this, 'get_test_posts'],
'permission_callback' => [$this, 'check_permissions'],
]);
// Add error response for unsupported HTTP methods for test product retrieval
register_rest_route($this->namespace, '/test-product', [
'methods' => 'POST,PUT,PATCH,DELETE,HEAD,OPTIONS',
'callback' => [$this, 'unsupported_method'],
]);
}
public function get_test_posts() {
// Query 'test' posts
$args = [
'post_type' => 'test', // Replace with your custom post type slug
'posts_per_page' => -1, // Retrieve all posts
];
$test_posts = new WP_Query($args);
$response = [];
if ($test_posts->have_posts()) {
while ($test_posts->have_posts()) {
$test_posts->the_post();
// Get the post ID
$post_id = get_the_ID();
// Get custom fields associated with the post
$network = get_field('network');
$discount = get_field('discount');
$type = get_field('type');
// Add the data to the response
$response[] = [
'id' => $post_id,
'network' => $network,
'discount' => $discount . '%',
'type' => $type,
];
}
}
// Return the response
return $response;
}
// General User permission
public function check_permissions() {
return current_user_can('read');
}
// UNSUPPORTED Request Method
public function unsupported_method() {
return new WP_Error('unsupported_method', 'Unsupported HTTP Method', ['status' => 405]);
}
}
// Instantiate the class when the file is included
$test_endpoints = new TestEndpoints();
I have the file here https://we.tl/t-pnmkrax7Ev
I would appreciate any help please
I’m creating a custom plugin. Poylang is installed and configured in WordPress (both latest version). The plugin uses an own mailer.
Can’t get the translatiions of the Mailtext working. Following error is thrown:
Fatal error: Uncaught Error: Call to undefined function pll__() in PATH/TO/PLUGIN/inc/mailing/mailer.php:36 Stack trace: #0
This is the corresponding line:
$content = pll__("mailafterregistration");
The hole code (just trying) of the function is:
function MailAfterRegistration($userguid) {
$content = pll__("mailafterregistration");
$subject = pll__("mailafterregistrationsubject");
$usermail ) = "[email protected]"
SendMail($content, $subject, $usermail);
}
function SendMail($content, $subject, $to) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: XXXXXXXX' . "\r\n";
$headers .= 'Bcc: XXXXXXX' . "\r\n";
mail($to, $subject, $content, $headers);
}
Can anyone help withj this please? I think I’m missing an include or so?
Edit: the strings are registered correctly and can be used in other parts of the custom plugin. For example:
function GetSingleText() {
$out = '<p>. pll__("mailafterregistration") . '</p>':
return $out;
}
]]>I have two questions regarding the customization of this plugin.
How can I change the text of the “Submit” button? I’m looking to modify this part of the code: <input type=”submit” name=”gwolle_gb_submit” class=”gwolle_gb_submit button btn btn-primary” value=”I WANT THIS TO BE MY VALUE”>
and my second question, Is there a way to change the label of the textarea element. Part of code here: <label for=”gwolle_gb_content” class=”text-info”>I WANT TO CHANGE THIS TEXT TO MY CUSTOM LABEL<span class=”required”>*</span></label>
I know I can achieve this by editing the file located in /frontend/gb-form.php, but my modyfications will be overwritten after the plugin update. Also I know that I can create childtheme and store modyfication in there, but I think it’s not a good idea.
I’ve heard that there are some modifications for WordPress called hooks or filters(?), but I’m not able to write the code as I’m not a php programmer, and I just don’t understand how it works.
Could you please help me to solove this little problem?
]]>Like, I have written blog on The Skindex. so Now I want to create a plugin where user can directly review their opinion on Minecraft.
Please let me know if you have any suggestions.
Thanks
]]>I’m creating a little plugin to display “user total points balance” and “user points balance’s value” using shortcodes I can display anywhere.
For now I’m using direct database access to calculate the result but I guess that you guys have some more efficient functions/filters I should trigger to make it more sustainable ?
Best regards,
]]>