Choose and assign questions (CPT) to quizes

I have created a special type of post (which is also a woo product), named Quizes (post_type => quiz). I also have another CPT, named Questions (post_type => question), which stores a multitude of questions and their multiple choice answers (the latter as their postmeta). As you can guess, the relationship between those two will be many-to-many, meaning that each quiz will have many questions, and each question can be assigned to many quizes... Anyway, what I want is an …
Category: Web

Wordpress plugin not finding Composer Autoloader

When I try to use Autoload in my Wordpress plugin I get an unexpected error: not finding Warning: require(/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php): failed to open stream: No such file or directory in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 Fatal error: require(): Failed opening required '/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php' (include_path='.:/usr/share/php') in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 I've uploaded the files via SFTP Called require_once("vendor/autoload.php"); in the plugin entry file (it works) *The autoload.php file contains require_once DIR . '/composer/autoload_real.php';
Category: Web

WordPress Export table as csv using Ajax

Hello guys i'm trying to export my plugin table in the same page, i tried to do hidden iframe but it's still not works, can you kindly check my code please? thanks. PHP: add_action( "wp_ajax_export_plugin", "export_plugin" ); //update_records is action add_action( "wp_ajax_nopriv_export_plugin", "export_plugin" ); function export_plugin(){ global $wpdb; $wpdb->show_errors = TRUE; $wpdb->suppress_errors = FALSE; $plugin_name = $_POST['plugin-name']; // PLUGIN NAME $plugin_export_type = $_POST['export-type']; // PLUGIN EXPORT TYPE as CVS/SQL/XML $plugin_name; // ?? not defined in original code $results = $wpdb->get_results("SELECT …
Category: Web

Looping through and combining calls to Woocommerce REST API

I have to make calls to multiple pages of a Woocommerce product database (getting all products in one go seems to not be an option), and the looping and collection of the results isn't working as I expect. I should see an array with just under 900 objects, but all I'm seeing is an empty array. I'm very new to PHP. THe relevant code below: function get_awesome_products() { for ($count = 1; $count <= 9; $count++ ) { if ($count …
Category: Web

wp_remote_get keeps timing out

I'm making a plugin that compares data from external API with meta items in WordPress backoffice. I tried using wp_remote_get method to query my API but it doesn't return anything, nobody, nothing. When accessed directly with the same URL in browser the API generates JSON array without problems. What am I doing wrong? This is (partially omitted code in the plugin) .......... $chopped = explode("@", $meta['Email'][0]); $url = 'http://example.com/api/users/'.$chopped[0].'/'.$chopped[1]; global $wp_version; $args = array( 'timeout' => 5, 'redirection' => 5, …
Category: Web

How to change "Read More" text?

I'm using blogstart wordpress theme and I would like to change "Read more" text to something similar to language than I'm using. How can I do that? I already tried to paste code below to functions.php. Replaces the excerpt "Read More" text by a link function modify_read_more_link() { return '<a class="read-article" href="' . get_permalink() . '">Your Read More Link Text</a>'; } add_filter( 'the_content_more_link', 'modify_read_more_link' ); // Replaces the excerpt "Read More" text by a link function new_excerpt_more($more) { global $post; …
Category: Web

Wordpress cron job running more than once

I developed a plugin to read some XML files and publish their itens as post but for some reason, sometimes, it is duplicating posts. Basically that is what I have: // function one is scheduled (hourly) and unscheduled on plugin activation and deactivation hooks register_activation_hook(__FILE__, 'function_one_activation'); register_deactivation_hook(__FILE__, 'function_one_deactivate'); function function_one_activation() { if (!wp_next_scheduled('function_one_cron')) { wp_schedule_event(time(), 'hourly', 'function_one_cron'); } } function function_one_deactivate() { $timestamp = wp_next_scheduled('function_one_cron'); wp_unschedule_event($timestamp, 'function_one_cron'); } add_action('function_one_cron', 'one'); add_action('function_two_cron', 'two'); add_action('function_three_cron', 'three'); function one() { // download XML …
Category: Web

How to use wp_send_json() and output the value with ajax?

Hello Wordpress Developers. I create my own plugins, and I'm stuck about how to call php functions inside class, into javascript ajax functions. For example we have button with ID name clickme: <button id="clickMe">Click Me</button> And then I make a class with functions, example like this: <?php class myFunctions{ function a(){ $test = "Hello World from wp_send_json()"; wp_send_json($test); } } ?> and then I want to output the test variable, using ajax. Example like this: import $ from "jquery"; class …
Category: Web

Visual composer custom element error

I am creating a custom element where I need to load woo-commerce product categories as dropdown (in visual composer element edit option) but I am getting this error. can someone tell me where is the problem? here is the code: <?php add_shortcode('woo_my_cat_sub_cat_show_element_code','woo_my_cat_sub_cat_show_element_functions'); function woo_my_cat_sub_cat_show_element_functions($atts,$content){ extract(shortcode_atts(array( 'woo_my_cat_list' => '', ),$atts)); ob_start();?> <!-- I will do the frontend here --> <?php return ob_get_clean(); } if(function_exists('vc_map')){ /*** * dynamic fields for the element */ $args = array( 'taxonomy' => 'product_cat', // 'number' => …
Category: Web

Automated Cart Update With Alert Box Each Time

New To PHP and, I am currently attempting to create a plug in that creates an alert box every time the quantity in a cart is changed. So far I have successfully implemented updating the cart automatically, but I am having trouble determining how to create an alert box on update each time that references the new cart total. Any advice would be appreciated. TLDR: Creating a plug in that will display an alert box when you change the quantity …
Category: Web

SSL certificate verify failed

I have a gift voucher plugin for wordpress that creates a PDF after a user has finished filling in a form and sends it to the users email. This plugin uses the fpdf library to create the pdf. It worked fine before my web hotel installed OpenSSL/1.0.2g. Now I think that the SSL certificate blocks the pdf creation. I'm getting the following error message: PHP Warning: fopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed …
Category: Web

Ajax not working to insert, query and result data

On my site, through a form I send/register same information in database, do a SELECT/query and return it! Return the last table saved in database, just that user just entered on the form (along with some more information coming from the database). How I want to display these values coming from databse in a modal bootstrap it's necessary that the page doesn't give the refresh. For this, I inserted the AJAX as follows: $(document).ready(function(){ $('#enviar').click(function(){ $.ajax({ //CAAL AJAX IN WORDPRESS …
Category: Web

WooCommerce plugin acceptance time

We have been waiting for an acceptance of our plugin for WooCommerce since September 2021. A month or so ago we got a reply that not long left. The solution is already in use by a number of customers, but we would like to have it more easily available. The same solution is already accepted by Shopify and Magento with many more happy customers. I really dont understand what is this, zero feedback so no changes requested. Are we getting …
Category: Web

Using Product variations as product addons

This is more a question for advice than a bug or problem. I'm building a Woocommerce based plugin and I was looking to at way of using the core woocommerce/ wordpress as best as possible without the need for dependencies. My question for advice centres around using variations also as product addons as I'm trying to develop the functionality of being able to Offer "checkbox" type variations Allow selection of multiple variations per attribute that is used for the variations …
Category: Web

Generate and send ICS file through WordPress

I'm writing a custom plugin for reservations. I need to generate an .ics file that needs to be sent to a predefined email address. I've tried some library like ZContent iCalendar and a PHP script that I found on github that I've included inside my plugin code. The script works well and I can obtain a valid output. The problem is I can't figure out how to generate the ics file and attach it to an email using the wp_mail …
Category: Web

Gutenberg default attributes are empty when accessing in edit

I'm quite new to Gutenberg and Wordpress and facing some issues with my attribute. When I'm trying to output the attribute data it is returning an empty object. Not quite sure why the default values aren't being applied? Thanks in advance! registerBlockType("mt/product-listing", { title: "Product", icon: "edit-page", category: "design", attributes: { content: { type: 'string' } }, ..., And when trying to access in edit: edit: (props) => { // Accessing props console.log("Edit", props); return ( <div> <Products product={props.attributes} /> …
Category: Web

WP Cron as Fast as WordPress AJAX?

I have a question about performing a very long and resource intensive task within WordPress. Here is the scenario. I have a plugin that allows users to run a task that takes a very long time and once completed will return the result back to the user. The first thing I did was run the task via WordPress AJAX functions. This did not work since the site locked up to that user. Meaning that if the task was started then …
Category: Web

The Events Calendar featured image as body background?

<?php if (has_post_thumbnail( $post->ID ) ): $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); elseif (tribe_event_featured_image( $event_id = get_the_ID())): $thumb = get_attachment_image_src(tribe_event_featured_image( $event_id), 'large' ); else: $thumb = array(get_template_directory_uri().'/images/background.jpg'); endif;?> <body <?php body_class(); ?> style="background-image: url('<?php echo $thumb['0'];?>') no-repeat fixed"> Hello Sir Experts, Please help, i am using "The Events Calendar" plugin, and i want to use event featured image as body backgound. Please check code! and it's demo event page: http://rankonone.com/dev/downtown/event/the-lion-king/
Category: Web

How to debug new shortcode? And how to get string from shortcode into code?

I am trying to write a simple plugin that fetches some data from an API endpoint. I am planning to read the api key from a shortcode, but didn't get that far yet. I wrote the following piece of code. The noob question I have is how do I even trigger the code so that I could debug it to see what happens ? If that's a simple question, the follow up would be how to read the api key …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.