Skip to content

Instantly share code, notes, and snippets.

Avatar
👀
looking for purest...

Ali Mirzaei Alimir

👀
looking for purest...
View GitHub Profile
@Alimir
Alimir / wp-ulike.php
Created Apr 30, 2021
Restrict like/dislike based on period time for 10 days after post publish
View wp-ulike.php
<?php
/**
* Restrict period time for 10 days after post publish
*
* @param integer $id
* @param string $type
* @return void
*/
function wp_ulike_pro_custom_restrict_period_time( $id, $type ){
@Alimir
Alimir / wp-ulike.php
Last active Apr 28, 2021
Migrate counter values from LikeBtn to WP ULike
View wp-ulike.php
<?php
add_action( 'admin_action_migrate_likebtn_to_wp_ulike', 'migrate_likebtn_to_wp_ulike_admin_action' );
function migrate_likebtn_to_wp_ulike_admin_action(){
global $wpdb;
// Do your stuff here
if( empty( $_POST['posts'] ) && empty( $_POST['comments'] ) ){
wp_die( 'Please select an option!' );
}
@Alimir
Alimir / wp-ulike-pro.php
Last active May 3, 2021
Filter posts by like amount in elementor post widget
View wp-ulike-pro.php
<?php
add_action( 'elementor/query/order_by_like_amount', function( $query ) {
// Get current meta Query
$meta_query = $query->get( 'meta_query' );
// If there is no meta query when this filter runs, it should be initialized as an empty array.
if ( ! $meta_query ) {
$meta_query = [];
}
@Alimir
Alimir / wp-ulike.php
Created Apr 22, 2021
Limit user to vote per day by cookie method
View wp-ulike.php
<?php
function wp_ulike_custom_permission_status( $status, $args, $settings ){
$cookie_key = sanitize_key( 'wp_ulike_manual_' . $args['type'] . $args['item_id'] );
$has_cookie = false;
if( isset( $_COOKIE[ $cookie_key ] ) ) {
$status = false;
$has_cookie = true;
} else {
@Alimir
Alimir / wp-ulike-pro.php
Last active Apr 22, 2021
Ultimate member user acitivity counter
View wp-ulike-pro.php
<?php
/**
* Create shortcode: [wp_ulike_pro_um_counter]
*
* @param array $atts
*
* @return integer|string
*/
function wp_ulike_pro_get_um_counter( $atts ){
@Alimir
Alimir / wp-ulike-pro.php
Last active Apr 22, 2021
Add new password field inside wp ulike edit account form
View wp-ulike-pro.php
<?php
/**
* Add new fields to account form
*
* @param string $type
* @param array $args
* @return void
*/
function wp_ulike_pro_customize_account_form( $type, $args ){
@Alimir
Alimir / wp-ulike-pro.php
Created Apr 13, 2021
A sample shortcode to display attachments recently liked by the user (Inside ulike profile panel)
View wp-ulike-pro.php
<?php
function wp_ulike_custom_shortcode_attachment(){
global $wp_ulike_user_profile_id;
$post__in = wp_ulike_get_popular_items_ids(array(
'type' => 'post',
'rel_type' => 'attachment',
'status' => array( 'like', 'dislike' ),
'period' => 'all',
@Alimir
Alimir / wp-ulike.php
Created Apr 6, 2021
How to disable unlike method at wp ulike
View wp-ulike.php
<?php
add_filter( 'wp_ulike_permission_status', function( $status, $args , $settings ){
if( ! empty( $args['prev_status'] ) ){
return false;
}
return $status;
}, 10, 3 );
@Alimir
Alimir / wp-ulike.php
Last active Mar 27, 2021
Display wp ulike buttons only in the comments section of buddypress (Don't forget to disable auto display option inside settings panel)
View wp-ulike.php
<?php
/**
* Display like button inside comment options section
*/
add_action( 'bp_activity_comment_options', function(){
echo wp_ulike_buddypress('put');
}, 15 );
/**
@Alimir
Alimir / wp-ulike-pro.php
Created Mar 18, 2021
wp ulike count total likes and dislikes
View wp-ulike-pro.php
<?php
function wp_ulike_custom_count_logs( $atts ){
// Global variable
global $wpdb;
// Default Args
$args = shortcode_atts( array(
"status" => 'like',
"type" => 'post'