Run command “composer install” when activating wordpress plugin

I want to run the command : "composer install –prefer-dist" in a wordpress plugin in the hook register_activation_hook to install the require vendors. But when I trying to activating the plugin the error below is generate. Do you have a way to install the required composers when activate the plugin?

Fatal error: Uncaught Error: Class ‘App\XXXXX’ not found in /../wordpress/wp-content/plugins/my-plugin/my-plugin.php:54 Stack trace: #0 /../wordpress/wp-admin/includes/plugin.php(2300): include() #1 /../wordpress/wp-admin/plugins.php(191): plugin_sandbox_scrape(‘my-plugin/my-…’) #2 {main} thrown in /../wordpress/wp-content/plugins/my-plugin/my-plugin.php on line 54

Assign wordpress featured images via external URL based on numeric value in custom fields

I have several posts (150) with a custom field ‘floorplan-image-id’ which has a unique value (number) that feeds from XML. The featured image for each post should be automatically assigned via external URL based on the above custom field value.

Example: if floorplan-image-id = 12345 then the Featured image will be : //someurl.com/images/floorplan-1.png

else if floorplan-image-id = 34567 then the Featured image will be : //someurl.com/images/floorplan-2.png

====================

function custom_floorplan-image($ html, $ post_id, $ meta_field) {

$ meta_field = get_post_meta($ post->ID, ‘floorplan-image-id’, true);

if ($  meta_field === '12345') {     $  html = "<img src='"//mysite.com/images/Floorplan_A1.png"'>"; }else if ($  meta_field === '34567') {     $  html = "<img src='"//mysite.com/images/Floorplan_A2.png"'>"; }  return $  html; 

}

add_filter(‘post_thumbnail_html’, ‘custom_floorplan-image’, 10, 3);

WordPress plugin called “YITH WooCommerce Questions and Answers Premium”, Its data is not showing in REST API’s

I am using a plugin to add questions and answers to Woocomerce products, it works fine on webiste but when I try to get data through API those questions and answers are not in cluded in API. And this plugin is not using any post type so we can get data separately. What i can do now?

[Hostpoco.com]Best WordPress Hosting @ $ 0.5/m + Unlimited Space + FREE cPanel.

Get the low-cost and best WordPress hosting package with Hostpoco.com. Now WordPress has become one of the most popular website building platforms. Every WordPress blogger or a WordPress Developer looking for a fully loaded WordPress hosting service that is isolated from other users on the server, Hostpoco provides you everything for which you have been waiting for.

we are offering special WordPress hosting plans starting from half a dollar per month along with a single click script installer where you can install WordPress in a single click also can take backups and can finish upgrading part from there. All WordPress/Application hosting plans come with no limit for resources and will be the perfect choice for high traffic blogs or sites.

Also, Our team has developed a special package for supporting all major online solutions for your needs like Magento, Opencart, Joomla WordPress, Drupal. You can upgrade your hosting package as you grow.

Half Dollar WordPress Hosting Include:
– Single Domain Hosting
– Unlimited Web Space
– Unlimited Bandwidth
– 5 Email Accounts
– 2 Parked Domains
– 2 MySQL Databases
– 5 Sub Domains
– RAID 10 HDD Storage
– Cheap Shared Hosting
– FREE cPanel Control Panel
– FREE PHP MyAdmin
– FREE AwStats
– FREE Auto SSL
– FREE Virus Scanner
– DDOS Protection
– 99.99% uptime
– Softacolous Supported
– Tier 1 Technical Support

For more details on WordPress Hosting plans visit: https://www.hostpoco.com/half-dollar-wor…osting.php

Have any questions?
Do not hesitate to drop us a support email at sales@hostpoco.com OR visit our page to chat with our Live Chat Support.
http://www.hostpoco.com

Best WordPress Hosting, Unlimited Space, Unlimited bandwidth – Hostbazzar!

Hostbazzar is pleased to announce the most affordable web hosting plans, starting from $0.5 per month and $6 per year.
These packages are especially suitable for small and medium webmasters or webdesigners. We hire support staffs from
different locations like US and India to make sure that all tickets can be answered and all problems can be resolved
in as short time as possible.

Our team have develop special package for supporting all major online solutions for your needs like: Magento,Opencart,
Joomla WordPress,Drupal and all these can be installed in single click.

Key Features offered with Best wordpress hosting:

HDD Unlimited Space
US / France location Servers
cPanel as control panel
Not oversold servers
Softaculous App Installer
Unlimited Bandwidth
Unlimited FTP Accounts
Unlimited Databases
Unlimited Subdomains
Unlimited Domains
Unlimited Email Accounts
Easily install WordPress, and other applications
No Setup Fees
Instant Setup
Free SSL
Free Migration
Fast and Stable Network
Privacy Assured
99.9% Guaranteed Uptime
Free & Instant Set-up
24/7 Support
30 Days Money Back Guarantee
The Best Service at a Fair Price

For Order : https://hostbazzar.com/free_wordpress_hosting.php

Thanking you.

WordPress Custom Cart

hello guys i have a created a wordpress site and i am using rest api to display the products n categories in my app

in that i have created a custom cart php file where i am getting the productid n name etc..

i want to add some additonal parameters when the product is added to cart, i saw extra product option plugin in wordpress so how can i integrate my custom cart to extra product option or how to add additional parameters to my cart so i can send the data when user clicks on add to cart in app.

how can i implement this n i m using _woocommerce_persistent_cart_1

below is my php code

<?php  /**  * REST API Webhooks controller  *  * Handles requests to the /webhooks endpoint.  *  * @package Automattic/WooCommerce/RestApi  * @since   2.6.0  */  defined( 'ABSPATH' ) || exit;  /**  * REST API Webhooks controller class.  *  * @package Automattic/WooCommerce/RestApi  * @extends WC_REST_Webhooks_V2_Controller  */ class WC_REST_Webhooks_Controller extends WC_REST_Webhooks_V2_Controller {      /**      * Endpoint namespace.      *      * @var string      */     protected $  namespace = 'wc/v3';      /**      * Get the default REST API version.      *      * @since  3.0.0      * @return string      */     protected function get_default_api_version() {         return 'wp_api_v3';     }          protected $  rest_base = 'custom';      function woocomm_add_to_cart($  param) {          global $  wpdb;         $  user_id = $  param['user_id'];         wp_set_current_user($  user_id);          $  objProduct = new WC_Session_Handler();              $  wc_session_data = $  objProduct->get_session($  user_id);                  // Get the persistent cart may be _woocommerce_persistent_cart can be in your case check in user_meta table         $  full_user_meta = get_user_meta($  user_id,'_woocommerce_persistent_cart_1', true);          if ( defined( 'WC_ABSPATH' ) ) {             // WC 3.6+ - Cart and other frontend functions are not included for REST requests.             include_once WC_ABSPATH . 'includes/wc-cart-functions.php';             include_once WC_ABSPATH . 'includes/wc-notice-functions.php';             include_once WC_ABSPATH . 'includes/wc-template-hooks.php';         }          if ( null === WC()->session ) {             $  session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );              WC()->session = new $  session_class();             WC()->session->init();         }          if ( null === WC()->customer ) {                         WC()->customer = new WC_Customer( get_current_user_id(), true );         }                  if ( null === WC()->cart ) {             WC()->cart = new WC_Cart();              // We need to force a refresh of the cart contents from session here (cart contents are normally refreshed on wp_loaded, which has already happened by this point).             WC()->cart->get_cart();         }                  // create new Cart Object         $  cartObj = WC()->cart;                           // Add old cart data to newly created cart object         if($  full_user_meta['cart']) {                        foreach($  full_user_meta['cart'] as $  sinle_user_meta) {                               $  cartObj->add_to_cart( $  sinle_user_meta['product_id'], $  sinle_user_meta['quantity'], $  sinle_user_meta['variation_id']  );             }         }              // Add product and quantities coming in request to the new cart object         if($  param['products']){             WC()->cart->empty_cart();             foreach($  param['products'] as $  prod) {                 $  cartObj->add_to_cart( $  prod['product_id'], $  prod['quantity'], $  prod['variation_id']  );                             }         }                  $  updatedCart = [];         foreach($  cartObj->cart_contents as $  key => $  val) {             unset($  val['data']);             $  updatedCart[$  key] = $  val;         }          // If there is a current session cart, overwrite it with the new cart         if($  wc_session_data) {             $  wc_session_data['cart'] = serialize($  updatedCart);             $  serializedObj = maybe_serialize($  wc_session_data);               $  table_name = 'wp_woocommerce_sessions';              // Update the wp_session table with updated cart data             $  sql ="UPDATE $  table_name SET session_value= '".$  serializedObj."' WHERE  session_key = '".$  user_id."'";              // Execute the query             $  rez = $  wpdb->query($  sql);         }                       // Overwrite the persistent cart with the new cart data         $  full_user_meta['cart'] = $  updatedCart;                   $  productsInCart = [];         foreach($  cartObj->cart_contents as $  cart_item) {                                          $  product =  $  cart_item['variation_id'] == 0 ? wc_get_product( $  cart_item['product_id'] ) : wc_get_product( $  cart_item['variation_id'] );              $  image_id  = $  product->get_image_id();              $  image_url = wp_get_attachment_image_url( $  image_id, 'full' );              $  attributes =  $  product->get_attributes();                $  productsInCart[] = (object) [                 "product_id" => $  cart_item['product_id'],                 "product_name" => wc_get_product( $  cart_item['product_id'] )->get_name(),                 "product_regular_price" => $  product->get_regular_price(),                 "product_sale_price" => $  product->get_sale_price(),                 "thumbnail" => $  image_url,                 "qty" => $  cart_item['quantity'],                 "attribute" => $  attributes,                              "line_subtotal" => $  cart_item['line_subtotal'],                 "line_total" => $  cart_item['line_total'],                  "variation_id" => $  cart_item['variation_id'],                     ];         }                               update_user_meta(get_current_user_id(), '_woocommerce_persistent_cart_1', array('cart' => $  updatedCart, ));                           $  response = [             'status' => true,             'data' =>  $  full_user_meta['cart'] != null ?  $  productsInCart : []                   ];          return rest_ensure_response($  response);     }      function woocomm_cart_list($  param) {         $  user_id = $  param['user_id'];         $  objProduct = new WC_Session_Handler();          $  wc_session_data = $  objProduct->get_session($  user_id);          // Get the persistent cart may be _woocommerce_persistent_cart can be in your case check in user_meta table         $  full_user_meta = get_user_meta($  user_id,'_woocommerce_persistent_cart_1', true);                  $  productsInCart = [];         foreach($  full_user_meta['cart'] as $  cart_item) {                                          $  product =  $  cart_item['variation_id'] == 0 ? wc_get_product( $  cart_item['product_id'] ) : wc_get_product( $  cart_item['variation_id'] );              $  image_id  = $  product->get_image_id();              $  image_url = wp_get_attachment_image_url( $  image_id, 'full' );              $  attributes =  $  product->get_attributes();                $  productsInCart[] = (object) [                 "product_id" => $  cart_item['product_id'],                 "product_name" => wc_get_product( $  cart_item['product_id'] )->get_name(),                 "product_regular_price" => $  product->get_regular_price(),                 "product_sale_price" => $  product->get_sale_price(),                 "thumbnail" => $  image_url,                 "qty" => $  cart_item['quantity'],                 "attribute" => $  attributes,                              "line_subtotal" => $  cart_item['line_subtotal'] ?? 0,                 "line_total" => $  cart_item['line_total'] ?? 0,                 "variation_id" => $  cart_item['variation_id'],                              ];         }                              $  response = [             'status' => true ,                           'data' =>  $  full_user_meta['cart'] != null ?  $  productsInCart : []               ];          return rest_ensure_response($  response);     }          public function register_routes() {         register_rest_route(             $  this->namespace,             '/addtocart',             array(                 'methods' => 'POST',                 'callback' => array( $  this, 'woocomm_add_to_cart' ),             )         );                  register_rest_route(             $  this->namespace,             '/cart',             array(                 'methods' => 'GET',                 'callback' => array( $  this, 'woocomm_cart_list' ),             )         );     } } 

Best theme/boiler plate for WordPress theme development in 2021?

I think I’m having an existential crisis. Six years ago, I began building WordPress websites using a pre-built theme, and I would just modify the child CSS, page builder, etc to make it look like my clients’ brand. Eventually, the sites started to get larger, with bigger budgets, so I had time to explore better options. I jumped on Underscores (_S), which is good, but there were lots of components I had to rebuild over and over. I switch to Understrap which I still like, but development has been slow, and I’m scared I’m going to become obsolete.

My question is, what is your build process for 2021 for larger projects (ones that take a few months overall) and what’s your Workflow?