snowbeachking
Forum Replies Created
-
Forum: Plugins
In reply to: [Post Notification by Email] Block Emails in two casesDone. 🙂
Forum: Plugins
In reply to: [Post Notification by Email] {date} is currently not translatablePoedit didn’t show the part for translation properly. My fault. Now translated.
Forum: Fixing WordPress
In reply to: How to customize the excerptI did some deeper research and came up with the following. I know that it won’t work, but some parts work as standalone, but I am not able to bring everything together. Maybe somebody can help to point me into the right direction?
function individual_excerpt_more( $more ) { if { function word_count() { $content = get_post_field( 'post_content', $post->ID ); $word_count = str_word_count( strip_tags( $content ) ); return $word_count; <45 // (less than 45 words) } && $content = $post->post_content; if( has_shortcode( $content, 'gallery', 'video' ) ) { // The content has a [gallery] & [video] short code, so this check returned true. } return '… <ins><a class="read-more" href="'. get_permalink( get_the_ID() ) . '">Read more</a></ins>'; } else { function theme_excerpt_length( $length ) { return 45; } add_filter( 'excerpt_length', ’theme_excerpt_length' ); } add_filter( 'excerpt_more', 'individual_excerpt_more' );Forum: Plugins
In reply to: [Post Notification by Email] Block Emails in two casesOk. Thanks for the link. Will have a look at it.
What about point 2:?
That is something I am not able to solve…Forum: Plugins
In reply to: [Post Notification by Email] Block Emails in two casesHi Valerio,
1: Not sure about this, because I do not have a use case for this at the moment.
2: Currently a notification is sent for new posts, pages and comments to everybody. I suggest not to send a notification mail to the writer/author of a new post, page or comment.
3: I am pretty new to WordPress. How does the fork work? I was thinking about just providing you the translation files.
Kind regards.
Forum: Plugins
In reply to: [Post Notification by Email] {date} is currently not translatableHi Valerio,
Thank you for your response. I used for translation ‘notify-users-e-mail.pot’, which is included in the plugin language directory.
When translating it is not possible to translate the word “at”, as it is not included in the .pot file.So when an automatic mail is sent and you have included {date}, it will always be date at time in the mail.
I believe this part of your code would need to be adjusted to be translation ready as well?
protected function get_formated_date( $date ) { $format = get_option( 'date_format' ) . ' ' . _x( '\a\t', 'date format', 'notify-users-e-mail' ) . ' ' . get_option( 'time_format' );It is the
. _x( '\a\t',I believe.Kind regards.
Hi Matty,
Thank you again for the support.
That is what I currently have:
<?php /** * Template Name: Subscribtion Management * Description: The template for displaying standard pages with sidebar. */ // One-click subscribe and unsubscribe buttons // echo "<h2>" . __('One Click Subscription / Unsubscription', 'subscribe2') . "</h2>\r\n"; // echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __("Subscribe to All", 'subscribe2') . "\" /> "; // echo "<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __("Unsubscribe from All", 'subscribe2') . "\" /></p>"; /** Subscribe/unsubscribe user from one-click submission */ function one_click_handler($user_ID, $action) { if ( !isset($user_ID) || !isset($action) ) { return; } $all_cats = $this->all_cats(true); if ( 'subscribe' == $action ) { // Subscribe $new_cats = array(); foreach ( $all_cats as $cat ) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id); $new_cats[] = $cat->term_id; } update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $new_cats)); if ( 'yes' == $this->subscribe2_options['show_autosub'] && 'no' != get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes'); } } elseif ( 'unsubscribe' == $action ) { // Unsubscribe foreach ( $all_cats as $cat ) { delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id); } delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed')); update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'no'); } } //end one_click_handler() get_header(); ?> <div id="primary" class="site-content" role="main"> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header><!-- end .entry-header --> <div class="entry-content clearfix"> <?php // the_content(); ?> <!-- One-click subscribe and unsubscribe buttons --> <p class="submit"><input type="submit" class="button-primary" name="subscribe" value="Subscribe to All" /> <input type="submit" class="button-primary" name="unsubscribe" value="Unsubscribe from All" /></p> </div><!-- end .entry-content --> </article><!-- end post-<?php the_ID(); ?> --> </div><!-- end #primary --> <?php get_footer(); ?>Your hint
call the function directly passing in the user ID and button action
brought me to some articles where it states that I need to use AJAX to use function for button click. Is that correct? If so, this doesn’t make it really easier for me. 🙁
Is my approach of having everything onto one site the easiest? Or what would you recommend for my goal of having just the two buttons on a page at the frontend?
I really appreciate your help.
Kind regards.
Hi Matty,
thanks for your feedback. Ok, I decided to build a template for my subscription page, where our family members can also manage their comments subscriptions. Therefore ignore the “if”. 🙂
But I am still struggling to get the two subscribe / unsubscribe buttons to work. 🙁
That is what I tried now…
<?php /** * Template Name: Subscribtion Management * Description: The template for displaying standard pages with sidebar. */ /** Subscribe/unsubscribe user from one-click submission */ function one_click_handler($user_ID, $action) { if ( !isset($user_ID) || !isset($action) ) { return; } $all_cats = $this->all_cats(true); if ( 'subscribe' == $action ) { // Subscribe $new_cats = array(); foreach ( $all_cats as $cat ) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id); $new_cats[] = $cat->term_id; } update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $new_cats)); if ( 'yes' == $this->subscribe2_options['show_autosub'] && 'no' != get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes'); } } elseif ( 'unsubscribe' == $action ) { // Unsubscribe foreach ( $all_cats as $cat ) { delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id); } delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed')); update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'no'); } } //end one_click_handler() add_action( 's2_one_click_subscription', 'one_click_handler' ); if (isset($wp_subscribe_reloaded)) { global $posts; $posts = $wp_subscribe_reloaded->subscribe_reloaded_manage(); } get_header(); ?> <div id="primary" class="site-content" role="main"> <?php do_action( 's2_one_click_subscription' ); // One-click subscribe and unsubscribe buttons echo "<h2>" . __('One Click Subscription / Unsubscription', 'subscribe2') . "</h2>\r\n"; echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __("Subscribe to All", 'subscribe2') . "\" /> "; echo "<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __("Unsubscribe from All", 'subscribe2') . "\" /></p>"; // Start the Loop. while ( have_posts() ) : the_post(); // Include the page content template. get_template_part( 'content', 'page' ); // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) { comments_template(); } endwhile; ?> </div><!-- end #primary --> <?php get_footer(); ?>Thanks for your patient assistance so far.
Kind regards.
Hi Matty,
Thank you for the hint. I put the following to my functions.php:
/** Subscribe/unsubscribe user from one-click submission */ function one_click_handler($user_ID, $action) { if ( !isset($user_ID) || !isset($action) ) { return; } $all_cats = $this->all_cats(true); if ( 'subscribe' == $action ) { // Subscribe $new_cats = array(); foreach ( $all_cats as $cat ) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id); $new_cats[] = $cat->term_id; } update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $new_cats)); if ( 'yes' == $this->subscribe2_options['show_autosub'] && 'no' != get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes'); } } elseif ( 'unsubscribe' == $action ) { // Unsubscribe foreach ( $all_cats as $cat ) { delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id); } delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed')); update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'no'); } } //end one_click_handler() function one_click_subscription( $content ) { // One-click subscribe and unsubscribe buttons echo "<h2>" . __('One Click Subscription / Unsubscription', 'subscribe2') . "</h2>\r\n"; echo "<span class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __("Subscribe to All", 'subscribe2') . "\" /> "; echo "<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __("Unsubscribe from All", 'subscribe2') . "\" /></span>"; } add_shortcode( 'one_click_subscription', 'one_click_subscription' );But still no success, which means that the clicks do not work. Just fyi. I am pretty new to all this and not a coder, but am willing to learn and have a very basic understanding of coding.
Thanks and kind regards.
Tried this one directly in your_subscriptions.php, as I prefer to use a short code – e.g. [one_click_subscription]:
if ( $this->subscribe2_options['one_click_profile'] == 'yes' ) { function one_click_subscription( $atts ) { // One-click subscribe and unsubscribe buttons echo "<h2>" . __('One Click Subscription / Unsubscription', 'subscribe2') . "</h2>\r\n"; echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __("Subscribe to All", 'subscribe2') . "\" /> "; echo "<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __("Unsubscribe from All", 'subscribe2') . "\" /></p>"; } add_shortcode( 'one_click_subscription', 'one_click_subscription' ); }Unfortunately it doesn’t work. Any help is much appreciated.
Forum: Plugins
In reply to: [Basic User Avatars] Translation in frontendGlad that it was useful to you.
I have an update with even less code to be added. 😉
class basic_user_avatars { private $user_id_being_edited; /** * Initialize all the things * * @since 1.0.0 */ public function __construct() { /** * Contributed by snowbeachking - Part 1 of 2 * Description: The "load_plugin_textdomain" function loads the plugin's translated strings. * If the path is not given then it will be the root of the plugin directory or the default WordPress * languages directory for the .mo plugin translation files. * Calling the function as early as the plugins_loaded action to enable the localization of the * front end as well. */ /* BEGIN Part 1 of 2 */ load_plugin_textdomain( 'basic-user-avatars' ); /* END Part 1 of 2 */ // Actions add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) ); add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) ); add_action( 'personal_options_update', array( $this, 'edit_user_profile_update' ) ); add_action( 'edit_user_profile_update', array( $this, 'edit_user_profile_update' ) ); add_action( 'bbp_user_edit_after_about', array( $this, 'bbpress_user_profile' ) ); // Shortcode add_shortcode( 'basic-user-avatars', array( $this, 'shortcode' ) ); // Filters add_filter( 'get_avatar', array( $this, 'get_avatar' ), 10, 5 ); add_filter( 'avatar_defaults', array( $this, 'avatar_defaults' ) ); } /** * Start the admin engine. * * @since 1.0.0 */ public function admin_init() { /** * Contributed by snowbeachking - Part 2 of 2 * Description: Disabled, because by the time you want to hook into the "load_plugin_textdomain" function, * it will be too late already since the "load_plugin_textdomain" call gets done immediately * when the plugin is loaded. */ // Load the textdomain so we can support other languages /* BEGIN Part 2 of 2 */ /* load_plugin_textdomain( 'basic-user-avatars', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); */ /* END Part 2 of 2 */Forum: Plugins
In reply to: [Basic User Avatars] Need .po fileHave a look at this post and create the translation files yourself using the WP plugin CodeStyling Localization.
Forum: Plugins
In reply to: [Basic User Avatars] Translation in frontendHi,
I am not a coder and therefore I cannot provide any further support to the following.If you want to use translation files for this plugin that work in the back- and front-end, then you will need to do add the following code to the init.php (version 1.0.0), at least it worked for me:
Have a look at the parts that start with “Author: snowbeachking”.
class basic_user_avatars { private $user_id_being_edited; /** * Initialize all the things * * @since 1.0.0 */ public function __construct() { // Actions add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) ); add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) ); add_action( 'personal_options_update', array( $this, 'edit_user_profile_update' ) ); add_action( 'edit_user_profile_update', array( $this, 'edit_user_profile_update' ) ); add_action( 'bbp_user_edit_after_about', array( $this, 'bbpress_user_profile' ) ); // Author: snowbeachking // Calling load_plugin_textdomain() during the init action and not earlier. add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); // Shortcode add_shortcode( 'basic-user-avatars', array( $this, 'shortcode' ) ); // Filters add_filter( 'get_avatar', array( $this, 'get_avatar' ), 10, 5 ); add_filter( 'avatar_defaults', array( $this, 'avatar_defaults' ) ); } /** * Start the admin engine. * * @since 1.0.0 */ public function admin_init() { /** * Author: snowbeachking * Disabled, because by the time you want to hook into the load_textdomain() function, it will be * too late already since the load_plugin_textdomain() call gets done immediately when the plugin * is loaded. * That is why we call load_plugin_textdomain() during the init action and not earlier. */ // Load the textdomain so we can support other languages // load_plugin_textdomain( 'basic-user-avatars', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); // Register/add the Discussion setting to restrict avatar upload capabilites register_setting( 'discussion', 'basic_user_avatars_caps', array( $this, 'sanitize_options' ) ); add_settings_field( 'basic-user-avatars-caps', __( 'Local Avatar Permissions', 'basic-user-avatars' ), array( $this, 'avatar_settings_field' ), 'discussion', 'avatars' ); } /** * Author: snowbeachking * load_plugin_textdomain() is called and gets told to load the applicable mo-files from the * subdirectory languages of the plugin’s directory or the default WordPress languages directory for * plugin translations. */ public function load_plugin_textdomain() { load_plugin_textdomain( 'basic-user-avatars', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); }