Skip to content

Commit

Permalink
4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelbart committed Oct 3, 2019
1 parent a29d7bb commit beedeb0
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 6 deletions.
1 change: 1 addition & 0 deletions core/classes/class-helpful-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function set_user_cookie() {
$string = bin2hex( openssl_random_pseudo_bytes( 16 ) );
$string = apply_filters( 'helpful_user_string', $string );
$lifetime = '+30 days';
$lifetime = apply_filters( 'helpful_user_cookie_time', $lifetime );

if ( ! session_id() ) {
session_start();
Expand Down
17 changes: 14 additions & 3 deletions core/classes/class-helpful-helper-feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public static function getAvatar( $email = null, $size = 55 ) {
}
}

return sprintf( '<img src="%1$s" height="%2$s" width="%2$s" alt="no avatar">', $default, $size );
$html = '<img src="%1$s" height="%2$s" width="%2$s" alt="no avatar">';
$html = apply_filters( 'helpful_feedback_noavatar', $html );

return sprintf( $html, $default, $size );
}

/**
Expand Down Expand Up @@ -120,7 +123,14 @@ public static function insertFeedback() {
$pro = 0;
$contra = 0;
$message = null;
$post_id = absint( $_REQUEST['post_id'] );

if ( ! isset( $_REQUEST['post_id'] ) ) {
$message = 'Helpful Notice: Feedback was not saved because the post id is empty in %s on line %d.';
helpful_error_log( sprintf( $message, __FILE__, __LINE__ ) );
return null;
}

$post_id = absint( sanitize_text_field( wp_unslash( $_REQUEST['post_id'] ) ) );

if ( ! isset( $_REQUEST['message'] ) ) {
$message = 'Helpful Notice: Feedback was not saved because the message is empty in %s on line %d.';
Expand All @@ -143,7 +153,7 @@ public static function insertFeedback() {
}

if ( isset( $_REQUEST['message'] ) ) {
$message = sanitize_textarea_field( wp_strip_all_tags( $_REQUEST['message'] ) );
$message = sanitize_textarea_field( wp_strip_all_tags( wp_unslash( $_REQUEST['message'] ) ) );
$message = stripslashes( $message );
$message = apply_filters( 'helpful_feedback_submit_message', $message );
}
Expand Down Expand Up @@ -219,6 +229,7 @@ public static function send_email( $feedback ) {
'{blog_url}' => site_url(),
];

$tags = apply_filters( 'helpful_feedback_email_tags', $tags );
$body = get_option( 'helpful_feedback_email_content' );
$body = str_replace( array_keys( $tags ), array_values( $tags ), $body );

Expand Down
1 change: 0 additions & 1 deletion core/classes/class-helpful-helper-optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ public static function clear_cache() {
* @return array
*/
public static function update_metas() {
$results = [];
$response = [];
$post_types = get_option( 'helpful_post_types' );

Expand Down
2 changes: 1 addition & 1 deletion core/classes/class-helpful-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function save_metabox_data( $post_id ) {
}

if ( isset( $_POST['helpful_feedback_receivers'] ) ) {
$receivers = sanitize_text_field( $_POST['helpful_feedback_receivers'] );
$receivers = sanitize_text_field( wp_unslash( $_POST['helpful_feedback_receivers'] ) );
update_post_meta( $post_id, 'helpful_feedback_receivers', $receivers );
}
}
Expand Down
36 changes: 36 additions & 0 deletions core/classes/class-helpful-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function __construct() {

add_action( 'admin_menu', [ $this, 'register_admin_menu' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
}

/**
Expand Down Expand Up @@ -296,4 +297,39 @@ public function enqueue_scripts() {
wp_localize_script( 'helpful-admin', 'helpful_admin', $vars );
}
}

/**
* Method for adding and filtering plugin row meta of Helpful.
*
* @param array $links default links.
* @param string $file file string.
*
* @return array
*/
public function plugin_row_meta( $links, $file ) {

if ( false !== strpos( $file, basename( HELPFUL_FILE ) ) ) {
$links['documentation'] = sprintf(
'<a href="%s" target="_blank">%s</a>',
'https://helpful-plugin.info/documentation/',
esc_html_x( 'Documentation', 'plugin row meta', 'helpful' )
);

$links['donate'] = sprintf(
'<a href="%s" target="_blank">%s</a>',
'https://www.buymeacoffee.com/pixelbart',
esc_html_x( 'Donate', 'plugin row meta', 'helpful' )
);

$links['support'] = sprintf(
'<a href="%s" target="_blank">%s</a>',
'https://wordpress.org/support/plugin/helpful/',
esc_html_x( 'Support', 'plugin row meta', 'helpful' )
);

$links = apply_filters( 'helpful_plugin_row_meta', $links );
}

return $links;
}
}
7 changes: 7 additions & 0 deletions core/classes/class-helpful-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ public function add_to_content( $content ) {
$default_template = HELPFUL_PATH . 'templates/helpful.php';
$custom_template = locate_template( 'helpful/helpful.php' );

do_action( 'helpful_before' );

if ( '' !== $custom_template ) {
include $custom_template;
} else {
include $default_template;
}

do_action( 'helpful_after' );

$content .= ob_get_contents();
ob_end_clean();

Expand All @@ -114,13 +118,16 @@ public function shortcode_helpful( $atts, $content = '' ) {
global $post;

$defaults = Helpful_Helper_Values::getDefaults();
$defaults = apply_filters( 'helpful_shortcode_defaults', $defaults );
$user_id = Helpful_Helper_Values::getUser();

if ( get_option( 'helpful_exists_hide' ) && Helpful_Helper_Values::checkUser( $user_id, $post->ID ) ) {
return;
}


$helpful = shortcode_atts( $defaults, $atts );
$helpful = apply_filters( 'helpful_shortcode_atts', $helpful );
$hidden = false;
$class = '';

Expand Down
2 changes: 1 addition & 1 deletion helpful.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
}

/* Include classes and functions */
require_once HELPFUL_PATH . 'core/autoload.php';
require_once HELPFUL_PATH . 'core/autoload.php';

0 comments on commit beedeb0

Please sign in to comment.