plugin development – Adding a picture as download [woo]

I’m looking for a hook, corresponding to event “creation of product” to make able set the download from product image to already set downloadable product. To the moment my plugin is creating products basing on user typed price, name, image file.
This code is working fine, but only at stage of manual “updating” of each product.

add_action( 'woocommerce_admin_process_product_object', 'set_url_dwnl', 5, 1);
function set_url_dwnl( $prd ) {
    $img_url = wp_get_attachment_image_url( $prd -> get_image_id(), 'full' );
    $img_meta = wp_get_attachment_metadata( get_post_thumbnail_id( $prd -> get_id() ), false );
    $dnld  = new WC_Product_Download();
        $dnld -> set_name( $img_meta('image_meta')('title') );
        $dnld -> set_id  ( md5($img_url) );
        $dnld -> set_file( $img_url );
    $downloads($md5_num) = $dnld;
    $prd -> set_downloads($downloads);
}

Can you advice another hook to freeze creation of product, adding one parameter: the download file?

plugin development – Conditional query tags do not work before the query is run. Before then, they always return false

I’m coding a plugin. When it’s loaded I check is_single() which returns the following error:

_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );

Where can I find the WP initializing process documentation?

How can I solve this issue?

plugin wpml – Missing Meta Keys on WooCommerce orders

I have a WPML problem with order language being ignored, and according to WPML it is because there is no meta keys in the metabox on orders. I only see attributes. Especially wpml_languages are missing.

I have a fresh install with the same theme, the same WP version and the same plugins – here I do not have this problem.

I have 3 sites from the same DB copy, one local, one for testing and one live. Everyone has this problem.

Have tried switching to a default theme, disabling all plugins, updating everything, etc. Nothing helps.

Any idea what could be causing this?

php – Calling a plugin function in a template

I’m using the WP-property plugin with the import addon. It imports properties from a local MLS. In the property edit screen, it displays the last import time and date in the meta box. I need to display this on the font end. (The plugin docs don’t provide a way to do this).

I found the function that displays this time and date (it is edited to suit my needs for a font-end display). The class name is class_wpp_property_import

      static public function wpp_publish_box_options( $id ) {
    global $post, $wp_properties;

    if( !$wpp_import_schedule_id = get_post_meta( $post->ID, 'wpp_import_schedule_id', true ) ) {
      return;
    }

    //** Get time stamp from new format ( Version 2.6.0+ ) */
    $import_time = get_post_meta( $post->ID, 'wpp_import_time', true );

    //** Get time stamp from old meta_key ( pre-version 2.6.0 ) if new meta_key does not exist */
    if( empty( $import_time ) ) {
      $import_time = get_post_meta( $post->ID, 'wpp_xml_import', true );
    }

    if( !empty( $import_time ) ) {
      $import_time = date_i18n( __( 'M j, Y @ G:i', ud_get_wpp_importer()->domain ), strtotime( $import_time ) );
      ?>

      <div class="misc-pub-section xml_import_time misc-pub-section-last">
        <span class="wpp_i_time_stamp"><?php printf( __( 'Imported on: <b>%1$s</b>', ud_get_wpp_importer()->domain ), $import_time, $import_url, $import_name ); ?>
          <b></b></span>
      </div>
    <?php
    }

  }

But when I add this (as a shortcode) I get a critical error. I’m using another plugin to create the shortcode easily.

I’ve also tried just using the HTML within the divs (also via shortcode) hoping that the function is firing anyhow, but no go. I’m wondering if it only fires on the backend.

Any help on this? I’ve been at it for a while and I think my brain is fried.

I tried calling the class, still get a critical error:

    class class_wpp_property_import {  
static public function wpp_publish_box_options( $id ) {
    global $post, $wp_properties;

    if( !$wpp_import_schedule_id = get_post_meta( $post->ID, 'wpp_import_schedule_id', true ) ) {
      return;
    }

    //** Get time stamp from new format ( Version 2.6.0+ ) */
    $import_time = get_post_meta( $post->ID, 'wpp_import_time', true );

    //** Get time stamp from old meta_key ( pre-version 2.6.0 ) if new meta_key does not exist */
    if( empty( $import_time ) ) {
      $import_time = get_post_meta( $post->ID, 'wpp_xml_import', true );
    }

    if( !empty( $import_time ) ) {
      $import_time = date_i18n( __( 'M j, Y @ G:i', ud_get_wpp_importer()->domain ), strtotime( $import_time ) );
      ?>

      <div class="misc-pub-section xml_import_time misc-pub-section-last">
        <span class="wpp_i_time_stamp"><?php printf( __( 'Imported on: <b>%1$s</b>', ud_get_wpp_importer()->domain ), $import_time, $import_url, $import_name ); ?>
          <b></b></span>
      </div>
    <?php
    }

  }}

The best WordPress plugin for Off page SEO. Try it free! | Forum Promotion

Running WordPress based solution and looking to improve your OFFPage SEO?
You can stop here!
Check our Ultimate WordPress tool for off page SEO: https://offpageseo.io/

Main features included:

Rank Reporter – check Google rank positions and get detailed analysis regarding link building
– Monitor Google SERP positions for up to every day change.
– Analyze positions in relation to backlinks you obtained.

Backlink management – record backlink, track if link is still present, get overview of total and monthly expenses
– Write down all your backlinks
– See total and monthly costs
– Automatically check if backlins are still present

Google Search Console – display data directly in your WordPress!
– Connect to Google Search Console to display the most successful pages and keywords
– Automatically links to keywords you track

You have 2 options:

Free
– Limited number of keywords (Requests are processed by your own server and we are limited by Google anti-scrape techniques of how many keyword we can get)
– Inconsistent results (Two reasons. You get results based on location of your server, not you as a user. And sometimes Google can prevent you from getting the results)
– Unlimited backlinks management
– Google Search Console connection
TRY NOW

Premium

– Unlimited number of keywords (The plugin sends all keywords you want to track to our API server, we do the work on our end and send you back the results)
– Consistent and precise results (We use servers across the globe based on your settings preferences)
– Unlimited backlinks management
– Google Search Console connection
$3/month
GET IT NOW

Have questions?
Please contact is via web site:
https://offpageseo.io/
or
ask your question here:
https://wordpress.org/support/plugin/off-page-seo/

 

Plugin for streamlining image post creation?

I have a photo gallery website, with one post for each image. Currently, the process for creating these posts is cumbersome: I click “add new post,” add the title and description, then click “set featured image,” find the photo, and add the same title and description (with different formatting). Is there a wordpress plugin that would streamline this process? That is, something like the flickr uploadr or a plugin that would allow me to iterate through the images in the media library and create a post for each?

theming – How to declare several templates for a Views row plugin

I want to create a custom Views display type called Card using Fields for the rows.
In my module I define the relevant plugins using hook_views_plugins as such:

function cards_format_views_plugins()
    {
      $path = drupal_get_path('module', 'cards_format');
      $plugins = array(
        'style' => array(
          'cards_format_style' => array(
            //  THEME
            'theme' => 'cards_format',
            'theme path' => $path . '/theme',
            //  HANDLER
            'handler' => 'cards_format_views_plugin_style_cards_format_style',
            'path' => $path . '/views/plugins',
            //  UI
            'title' => t('Cards'),
            'machine_name' => 'cards',
            'help' => t('Displays result in Cards using Material CSS'),
            //  OPTIONS
            'uses row plugin' => TRUE,
            'uses row class' => TRUE,
            'uses grouping' => TRUE,
            'uses options' => TRUE,
            'type' => 'normal',
          )
        ),
        'row' => array(
          'cards_format_fields' => array(
            //  THEME
            'theme' => 'cards_fields',
            'theme path' => $path . '/theme',
            //  HANDLER
            'handler' => 'cards_format_views_plugin_row_cards_format_row_style',
            'path' => $path . '/views/plugins',
            //  UI
            'machine_name' => 'cards_fields',
            'title' => t('Card Fields'),
            'help' => t('Displays fields in Cards using Material CSS'),
            // OPTIONS
            'uses fields' => TRUE,
            'uses options' => TRUE,
            'type' => 'normal',
          )
        )
      );
      return $plugins;
    }

I have created the relevant templates in my /theme folder : cards-fields.tpl.php and cards-format.tpl.php This works.

Now I want to handle two different cases with two different templates instead of the current cards-fields.tpl.php. When the card has an image I want cards-fields–image.tpl.php to be called and when it does not, cards-fields–no-image.tpl.php should be called.
So, I have declared a preprocessor tied to the theme function for fields cards_fields, which declares theme suggestion depending on the result, like so:

function template_preprocess_cards_fields(&$variables)
{

  $fields($label) =
  $variables('view')->render_field($label, $variables('view')->row_index);

  $image = $fields('field_basic_image');
  if($image){
   $variables('theme_hook_suggestions')() = 'cards__image_fields';
  }
  else {
   $variables('theme_hook_suggestions')() = 'cards__no_image_fields';
  }
}

I am stuck there, none of the templates corresponding to the theme suggestions are picked up, only the cards_fields.tpl.php one.

I assumed that preprocess functions could help declare custom templates regardless of whether there is a theme function declared in the plugin, but maybe I am missing something.

The best WordPress plugin for Off page SEO. Try it free! | Proxies-free

Running WordPress based solution and looking to improve your OFFPage SEO?
You can stop here!
Check our Ultimate WordPress tool for off page SEO: https://offpageseo.io/

Main features included:

Rank Reporter – check Google rank positions and get detailed analysis regarding link building
– Monitor Google SERP positions for up to every day change.
– Analyze positions in relation to backlinks you obtained.

Backlink management – record backlink, track if link is still present, get overview of total and monthly expenses
– Write down all your backlinks
– See total and monthly costs
– Automatically check if backlins are still present

Google Search Console – display data directly in your WordPress!
– Connect to Google Search Console to display the most successful pages and keywords
– Automatically links to keywords you track

You have 2 options:

Free
– Limited number of keywords (Requests are processed by your own server and we are limited by Google anti-scrape techniques of how many keyword we can get)
– Inconsistent results (Two reasons. You get results based on location of your server, not you as a user. And sometimes Google can prevent you from getting the results)
– Unlimited backlinks management
– Google Search Console connection
TRY NOW

Premium

– Unlimited number of keywords (The plugin sends all keywords you want to track to our API server, we do the work on our end and send you back the results)
– Consistent and precise results (We use servers across the globe based on your settings preferences)
– Unlimited backlinks management
– Google Search Console connection
$3/month
GET IT NOW

Have questions?
Please contact is via web site:
https://offpageseo.io/
or
ask your question here:
https://wordpress.org/support/plugin/off-page-seo/

 

plugin development – 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!