How to show the posts listing on dashboard or custom page in admin panel?

I want to show posts listing(almost like the default post listing page) on the dashboard page. And if that is not possible then maybe on a new page in the admin area.

Basically, I want to create a "My Desk" page for users where they can see some posts listed categorised by post meta. I’m fairly new to WordPress and can’t get an idea as to how this can be achieved.

Any help is appreciated, thank you!

Managing custom styles for the RSS widget via a plugin?

I help maintain a website that uses the RSS widget to display a feed of status updates. We manage site layout using Elementor, and we apply a chunk of custom CSS to the RSS widget in order to make it fit in with the rest of the website.

This works, but it’s not very manageable: we can’t version control the changes, and if we’re working on a staging site, getting things synced back to the production site is difficult if there have been significant changes to the production site since we split off the staging copy.

Is there a way to provide custom CSS for the feed widget via a plugin? We’re already doing that to modify the cache timeout (by setting wp_feed_cache_transient_lifetime); it would be great if there were a similar mechanism available for us to provide custom styles.

Associate custom field with custom taxonomy with shortcode in backend

I am trying to associate a custom field to a custom taxonomy booked_custom_calendar. Custom field here is [notifications_user_id]. All this will be executed using a shortcode. When user clicks on Generate Calendar button, a term will be created and assigned to the current user using custom field and current user’s email as value in it. In this way I can filter and show this term (booked_custom_calendar) anywhere by comparing the email of current user and value in custom field.

Please help me save this field to custom taxonomy.

function createMyCustomCalendar(){      $  current_user = wp_get_current_user();     $  custom_calendar_name = "$  current_user->display_name\'s - Calendar";          $  parent_term = term_exists( $  custom_calendar_name, 'booked_custom_calendars' ); // returns an array if the taxonomy exists     $  parent_term_id = $  parent_term['term_id']; // get the numerical value of the term          $  insert_data = wp_insert_term(     $  custom_calendar_name, // new term     'booked_custom_calendars', // taxonomy     array(     'description' => $  current_user->ID,     'slug' => '',     'parent' => $  parent_term_id     )     );     //Add new meta field and fill with user ID |     // add_term_meta($  term_id, 'term_author_id', $  current_user->ID, true);          if( ! is_wp_error($  insert_data) )     $  term_id = $  insert_data['term_id'];   // A callback function to add a custom field to our "presenters" taxonomy      // Check for existing taxonomy meta for the term you're editing       $  t_id = $  term_id; // Get the ID of the term you're editing       $  term_meta = get_option( "taxonomy_term_$  t_id" ); // Do the check   ?>      <tr class="form-field">        <td>           <input type="text" name="term_meta[notifications_user_id]" id="term_meta[notifications_user_id]" size="25" style="width:60%;" value="<?php echo $  current_user->data->user_email;?>"><br />       </td>   </tr>     <?php           //$  t_id = $  term_id;           //$  term_meta = get_option( "taxonomy_term_$  t_id" );           $  cat_keys = array_keys( $  _POST['term_meta'] );               foreach ( $  cat_keys as $  key ){                   $  term_meta[$  key] = $  _POST['term_meta'][$  key];                                    //save the option array           update_option( "taxonomy_term_$  t_id", $  term_meta );               }     echo '<script>window.location.replace("'.get_admin_url().'?page=booked-appointments");</script>';      }     function showCustomCalendarButton(){  ?>     <form method="post"> <input type="submit" name="button1"  id="btn-1" value="Generate Calendar"/></form>  <?php if(isset($  _POST['button1'])) { createMyCustomCalendar(); }  }  add_shortcode('create-custom-calendar','showCustomCalendarButton'); ?> <?php 

How to texture procedurally generated custom terrain mesh

I am making an infinite procedural terrain for my game and currently trying to apply textures to it. The generated terrain has different biomes, so I want to texturize the terrain based on biome and have different textures applied based on the steepness and height of the terrain. I also have different areas generated, such as settlements and also roads so I want to apply specific textures to specific places like those as well.

Unity terrain only supports I think 8 layers, but generally, it should be around 4 for 4 channels? In my case I generate a custom mesh, so I don’t really need to worry about this, however, I am trying to figure out how to generate some sort of texture map (splatmap), and have lots of textures in it. I want to use (albedo, normal, height) for each ‘layer’. Considering that the biomes are generated based on the noise map and each chunk can have many different biomes in it, I need to have more than 4 layers available. For example, steep areas like cliffs will need to have a rocky texture applied and each biome will have a different rocky texture. So if a chunk has two biomes in it, there are lots of different textures that need to be used, including various misc textures for paths and settlement grounds, etc.

Something like this, where a single chunk mesh has for example two biomes. Also, the terrain has a settlement that has a dirt texture applied to the terrain, which extends to both biomes. So essentially, lots of textures in just one mesh.

enter image description here

The other chunk(s) can have similar biomes or even completely other types of biomes. Also, would like to perhaps add the ability to apply different textures to a specific position on terrain chunk at runtime, for example, if the player would want to create a path or if a specific object is placed that would spread some specific texture around the object on the terrain. Something like this for example, where a placed tree has spread some leaf ground texture around:

enter image description here

So, I am looking for a flexible way in applying various different textures to generated terrain mesh. I would like to do that in the script when I am generating a chunk, so I would know which biomes is it at the position and as well as things like steepness and etc.

I am using Shader Graph to create the terrain shader. I’m not really experienced with shaders, so would like to ask for some help on what would be the correct way to achieve something like this?

Option for removing block not appearing in custom gutenberg block

I’m developing a custom gutenberg block. I’m able to get the fields to appear and I’m able to interact with it when adding it to a page. But the menu that allows you to remove the block does not appear when it’s highlighted. I’m referring to the menu in the screenshot below

enter image description here

I’m using the esnext syntax and this is what my main block js file looks like

    import "./style.scss"; import "./editor.scss";  const { __, setLocaleData } = wp.i18n; const {     registerBlockType, } = wp.blocks; const {     RichText,     MediaUpload, } = wp.editor; const { Button } = wp.components;  registerBlockType( 'tc-blocks/hero-block', {     title: __( 'Hero Block', 'tc-blocks' ),     icon: 'index-card',     category: 'layout',     attributes: {         title: {             type: 'string',             source: 'attribute',             selector: 'h2',         },         mediaID: {             type: 'number',         },         mediaURL: {             type: 'string',             source: 'attribute',             selector: 'img',             attribute: 'src',         },     },     edit: ( props ) => {         const {             className,             attributes: {                 title,                 mediaID,                 mediaURL,             },             setAttributes,         } = props;         const onChangeTitle = ( value ) => {             setAttributes( { title: value } );         };          const onSelectImage = ( media ) => {             setAttributes( {                 mediaURL: media.url,                 mediaID: media.id,             } );         };          return (             <div className={ className }>                 <RichText                     tagName="h2"                     placeholder={ __( 'Write Titleā€¦', 'tc-blocks' ) }                     value={ title }                     onChange={ onChangeTitle }                 />                 <div className="tc-image">                     <MediaUpload                         onSelect={ onSelectImage }                         allowedTypes="image"                         value={ mediaID }                         render={ ( { open } ) => (                             <Button className={ mediaID ? 'image-button' : 'button button-large' } onClick={ open }>                                 { ! mediaID ? __( 'Upload Image', 'tc-blocks' ) : <img src={ mediaURL } alt={ __( 'Upload Image', 'tc-blocks' ) } /> }                             </Button>                         ) }                     />                 </div>             </div>         );     },     save: ( props ) => {         const {             className,             attributes: {                 title,                 mediaURL,             },         } = props;         return (             <div className={ className }>                 <RichText.Content tagName="h2" value={ title } />                  {                     mediaURL && (                         <img className="tc-image" src={ mediaURL } alt={ __( 'Image', 'tc-blocks' ) } />                     )                 }             </div>         );     }, } ); 

Here’s how I’m registering the block type in my index.php file

function tc_blocks_hero_block_block_init() {     register_block_type_from_metadata( __DIR__ ); } add_action( 'init', 'tc_blocks_hero_block_block_init' ); 

And here’s my block.json file

{ "apiVersion": 2, "name": "tc-blocks/hero-block", "title": "Hero Block", "category": "widgets", "icon": "smiley", "description": "This is a header block built for a large hero image and text", "supports": {     "html": false }, "textdomain": "hero-block", "editorScript": "file:./build/index.js", "editorStyle": "file:./build/index.css", "style": "file:./build/style-index.css"  } 

I’ve compared my code to the gutenberg examples code found here https://github.com/WordPress/gutenberg-examples but I can’t seem to find any major differences that would cause an issue and I don’t see any js errors in the console.

How do I get the remove block menu to appear in my custom block?

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);

Hide Custom Taxonomy Editor for Specific Role(s) in WP Admin

I know you can select whether to hide or show various aspects of the custom taxonomy editor by passing arguments to the show_ui, meta_box_cb, or show_admin_column fields when registering. Something like:

register_taxonomy(     '',  //NAME OF CATEGORY     '', // NAME OF CUSTOM POST TYPE     array(         'show_ui' => true,         'meta_box_cb' => false,         'show_admin_column' => true     ) ); 

What I am wondering is how can I add a hook/filter beyond this so I check for the role of the current user and then set whether those arguments are true/false depending on the role?

I am here, but stuck:

add_action('in_admin_header', 'restrictTaxonomyEditBy'); function restrictTaxonomyEditBy() {     $  screen = get_current_screen();     $  user = get_current_user_id();     global $  post;         if(!current_user_can('administrator')) {         //ADJUST TAXONOMY PROPERTIES HERE TO HIDE/SHOW ADMIN UI     } } 

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' ),             )         );     } } 

Add custom post type as submenu

I have a custom post type called ‘Movies‘ that I want to add under WooCommerce menu after "Extensions" as you can see below:

enter image description here

The WooCommerce page URL is /wp-admin/admin.php?page=wc-admin

I tried:

register_post_type( 'movie', array(     'show_in_menu' => 'admin.php?page=wc-admin' ) ); 

but that didn’t work. I am able to set Movies under Tools, Settings, Post, etc everywhere else, just not inside WooCommerce. Any ideas why?