amjulash
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [GeneratePress] HTML tags in excerpt for custom post typesHi Alvind,
I think I tried it before, but checked again today and it did not work.
Thank you anyway.
Forum: Themes and Templates
In reply to: [GeneratePress] HTML tags in excerpt for custom post typesNo, it did not work. I tried that already.
Please share an email if you like to check it live on our staging website.
- This reply was modified 1 year ago by amjulash.
Forum: Themes and Templates
In reply to: [GeneratePress] HTML tags in excerpt for custom post typesHi,
I just confirmed again, the HTML tags in the excerpt works fine with Twenty Twenty-Five theme.
/**
* Allow HTML tags in member content when filtering member-restricted content.
* This is achieved by commenting out the line running the wp_strip_all_tags function
* for filtered member-only content.
*/
// First, let's remove the default pmpro_membership_content_filter.
function remove_pmpro_membership_content_filter() {
if ( ! function_exists( 'pmpro_membership_content_filter' ) ) {
return;
}
remove_filter( 'the_content', 'pmpro_membership_content_filter', 5 );
}
add_action( 'init', 'remove_pmpro_membership_content_filter' );
// Now let's add our own filter to allow HTML tags in member content.
add_filter( 'the_content', 'my_pmpro_membership_content_filter_allow_tags', 9 );
function my_pmpro_membership_content_filter_allow_tags( $content, $skipcheck = false ) {
global $post, $current_user;
if ( ! function_exists( 'pmpro_membership_content_filter' ) ) {
return $content;
}
if ( ! $skipcheck ) {
$hasaccess = pmpro_has_membership_access( null, null, true );
if ( is_array( $hasaccess ) ) {
//returned an array to give us the membership level values
$post_membership_levels_ids = $hasaccess[1];
$post_membership_levels_names = $hasaccess[2];
$hasaccess = $hasaccess[0];
}
}
/**
* Filter to let other plugins change how PMPro filters member content.
* If anything other than false is returned, that value will overwrite
* the $content variable and no further processing is done in this function.
*/
$content_filter = apply_filters( 'my_pmpro_membership_content_filter_allow_tags', false, $content, $hasaccess );
if ( $content_filter !== false ) {
return $content_filter;
}
if ( $hasaccess ) {
//all good, return content
return $content;
} else {
//if show excerpts is set, return just the excerpt
if ( pmpro_getOption( 'showexcerpts' ) ) {
//show excerpt
global $post;
if ( $post->post_excerpt ) {
//defined excerpt
$content = wpautop( $post->post_excerpt );
} elseif ( strpos( $content, '<span id="more-' . $post->ID . '"></span>' ) !== false ) {
//more tag
$pos = strpos( $content, '<span id="more-' . $post->ID . '"></span>' );
$content = substr( $content, 0, $pos );
} elseif ( strpos( $content, 'class="more-link">' ) !== false ) {
//more link
$content = preg_replace( '/\<a.*class\="more\-link".*\>.*\<\/a\>/', '', $content );
} elseif ( strpos( $content, '<!-- wp:more -->' ) !== false ) {
//more block
$pos = strpos( $content, '<!-- wp:more -->' );
$content = substr( $content, 0, $pos );
} elseif ( strpos( $content, '<!--more-->' ) !== false ) {
//more tag
$pos = strpos( $content, '<!--more-->' );
$content = substr( $content, 0, $pos );
} else {
//auto generated excerpt. pulled from wp_trim_excerpt
$content = strip_shortcodes( $content );
$content = str_replace( ']]>', ']]>', $content );
// $content = wp_strip_all_tags( $content ); -> So HTML stripping is off
$excerpt_length = apply_filters( 'excerpt_length', 100 );
// $words = preg_split( "/[\n\r\t ]+/", $content, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY ); -> so line break does not get removed
$words = preg_split( "/[\r\t ]+/", $content, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY );
// Check if there's a link in the first 100 words
$excerpt_text = implode( ' ', array_slice( $words, 0, 100 ) );
if ( preg_match( '/<a\s[^>]*href=[\'"]([^\'"]+)[\'"][^>]*>/i', $excerpt_text ) ) {
// Extend limit if a link is found
$excerpt_length = 120;
$words = preg_split( "/[\r\t ]+/", $content, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY );
}
if ( count( $words ) > $excerpt_length ) {
array_pop( $words );
$content = implode( ' ', $words );
$content = $content . '... ';
} else {
$content = implode( ' ', $words ) . '... ';
}
$content = wpautop( $content );
}
} else {
//else hide everything
$content = '';
}
$content = pmpro_get_no_access_message( $content, $post_membership_levels_ids, $post_membership_levels_names );
}
return $content;
}Hello, I was able to fix it. It seems with elementor pro enabled woocommerce recent viewed cookie was not working for me. So found a solution by forcing recently viewed cookie to always.
// Track product views. Always function wc_track_product_view_always() { if ( ! is_singular( 'product' ) /* xnagyg: remove this condition to run: || ! is_active_widget( false, false, 'woocommerce_recently_viewed_products', true )*/ ) { return; } global $post; if ( empty( $_COOKIE['woocommerce_recently_viewed'] ) ) { // @codingStandardsIgnoreLine. $viewed_products = array(); } else { $viewed_products = wp_parse_id_list( (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) ); // @codingStandardsIgnoreLine. } // Unset if already in viewed products list. $keys = array_flip( $viewed_products ); if ( isset( $keys[ $post->ID ] ) ) { unset( $viewed_products[ $keys[ $post->ID ] ] ); } $viewed_products[] = $post->ID; if ( count( $viewed_products ) > 15 ) { array_shift( $viewed_products ); } // Store for session only. wc_setcookie( 'woocommerce_recently_viewed', implode( '|', $viewed_products ) ); } remove_action('template_redirect', 'wc_track_product_view', 20); add_action( 'template_redirect', 'wc_track_product_view_always', 20 );Then set a custom posts query to show recently viewed products in elementor’s posts widget.
// Elemento posts query to show recently viewed products add_action( 'elementor/query/customquery', function( $query ) { // Get WooCommerce Global global $woocommerce; // Get recently viewed product cookies data $viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', $_COOKIE['woocommerce_recently_viewed'] ) : array(); $viewed_products = array_filter( array_map( 'absint', $viewed_products ) ); // If no data, quit if(empty($viewed_products)) { return; } $query->set( 'post__in', $viewed_products ); });Hope to see this fixed and support on elementor.
Thanks
JulashForum: Plugins
In reply to: [PDF Invoices & Packing Slips for WooCommerce] Unicode Font not ShowingHi, I am having the same issue with Bangla font and installed mPDF version from here https://github.com/wpovernight/woocommerce-pdf-ips-mpdf/releases, both CJK and non CJK.
But when mpdf version enable, whatever the template or with custom font for Simple MPDf version, bangla font showing as box.
It seems mpdf version is 2.2, are you not supporting it anymore. Really need your plugin for the sign feature after pdf downloads.
Thanks
JulashThank you very much for the plugin suggestion. But $200-$500/year for each location will surely hurt the store revenue.
Any way to do this using Woocommerce hooks for different user labels or user id?
Forum: Plugins
In reply to: [Stock Locations for WooCommerce] Force to buy from one location onlyHI Alex,
Thank you for your answer. Will locking cart going to prevent customers from adding products from different locations? Will this going to work for page builders like elementor?
In case of things do not work, I was thinking to add a custom widget with location dropdown somewhere and let customers select location only from that widget. That widget will store a cookie and I will modify product page location dropdown to only auto select the location user selected from the widget cookie. There will be css modifications, so once user select location from the widget, they wont be able to see other stock location on product and cart.
I only know very little about coding by searching, so not sure if this will work. But will try my best and let you know update.
Thanks
JulashI have followed this guide https://publishpress.com/blog/add-authors-woocommerce-products/ before submitting this support post. I also tried with “Change Product Author for WooCommerce”, “WC Author Change” plugin and the PHP function code mentioned on the above guide. But no luck.
To check if there any conflict with other plugin, I tried by deactivating all other plugging installed on my website except woocommerce and “PublishPress Authors”, still there no publisepress multi author box except just the single choice author box.
There was no box of publisepress multi author in Screen Option too.
Please kindly check.
Bytheway, do you think it will be possible to let woocommerce multi-vendors (multi author) to edit the same product with help of publishpress authors plugin using vendor plugin like WCFM from wc-lovers.com or dokan from wedevs.com/dokan?
Thanks
Julash