Skip to content

Instantly share code, notes, and snippets.

View Alimir's full-sized avatar
👀
looking for purest...

Ali Mirzaei Alimir

👀
looking for purest...
View GitHub Profile
@Alimir
Alimir / wp-ulike.php
Created June 1, 2023 15:31
Disable statistics & vote logs in wp ulike
<?php
function wp_ulike_pro_remove_admin_menus( $submenus ){
if( is_array( $submenus ) ){
if( isset( $submenus['statistics'] ) ){
unset($submenus['statistics']);
}
if( isset( $submenus['posts_logs'] ) ){
unset($submenus['posts_logs']);
}
if( isset( $submenus['comments_logs'] ) ){
@Alimir
Alimir / wp-ulike-pro.php
Last active April 3, 2023 13:15
Make user pinned posts query type for Bricks builder
<?php
/* Add new query type control to query options */
add_filter( 'bricks/setup/control_options', 'ulp_setup_query_controls');
function ulp_setup_query_controls( $control_options ) {
/* Adding a new option in the dropdown */
$control_options['queryTypes']['ulp_pinned_posts'] = esc_html__( 'WP ULike - User pinned posts' );
return $control_options;
@Alimir
Alimir / wp-ulike-pro.php
Created March 15, 2023 07:34
Add upload avatar field on account form
<?php
/**
* Add upload avatar field on account form
*
* @param string $type
* @param array $args
* @return void
*/
function wp_ulike_pro_custom_account_form( $type, $args ){
if( $type == 'profile' ):
@Alimir
Alimir / wp-ulike.php
Created February 9, 2023 12:08
wp ulike shortcode to get stats values
<?php
function wp_ulike_custom_stats_shortcode( $atts, $content = null ){
// Default Args
$args = shortcode_atts( array(
"period" => 'all' // you can use all, today, yesterday values
), $atts );
return wp_ulike_count_all_logs( $args['period'] );
}
add_shortcode( 'wp_ulike_custom_stats', 'wp_ulike_custom_stats_shortcode' );
@Alimir
Alimir / wp-ulike.php
Created September 27, 2022 08:17
Fix compatibility problem with the 'Simple Custom CSS and JS' plugin
<?php
add_filter('ulf_enqueue_assets',function($enqueue){
// Global object containing current admin page
global $pagenow;
if ( 'post.php' === $pagenow && isset($_GET['post']) && 'custom-css-js' === get_post_type( $_GET['post'] ) ){
return false;
}
return $enqueue;
@Alimir
Alimir / wp-ulike.php
Created July 15, 2022 17:14
wp ulike restrict user to vote x times at all
<?php
add_filter( 'wp_ulike_permission_status', function( $status, $args , $settings ){
$limit = 3;
if( $args['type'] == 'post' && ! empty( $args['current_status'] ) && strpos( $args['current_status'], 'un') === false ){
global $wpdb;
$query = sprintf( "
SELECT COUNT(*)
@Alimir
Alimir / wp-ulike.php
Created June 20, 2022 19:43
Add wp ulike block in the card builder (wpgridbuilder plugin)
<?php
function register_wp_ulike_block( $blocks ) {
$blocks['custom_field_image_block'] = [
'name' => 'WP ULike Button',
'render_callback' => 'render_wp_ulike_block',
];
return $blocks;
@Alimir
Alimir / wp-ulike.php
Last active August 8, 2022 16:52
wp ulike vote only 1 post per day
<?php
/**
* vote only for 1 post per day
*/
add_filter( 'wp_ulike_permission_status', function( $status, $args , $settings ){
if( $args['type'] == 'post' && ! empty( $args['current_status'] ) && strpos( $args['current_status'], 'un') === false ){
// if cookie has been set
if( isset( $_COOKIE['wphs'] ) && $args['item_id'] != $_COOKIE['wphs'] ){
return false;
@Alimir
Alimir / wp-ulike.php
Created May 23, 2022 20:41
custom likers template linked to wpforo profiles
<?php
/**
* Custom wp foro likers template
*
* @param string $template
* @param array $users_list
* @return string|null
*/
function wp_ulike_custom_likers_template_for_wpforo( $template, $users_list ){
@Alimir
Alimir / wp-ulike.php
Created April 25, 2022 15:12
Disable "votes" from buddypress filters
<?php
add_action( 'init', function(){
remove_action( 'bp_activity_filter_options', 'wp_ulike_bp_activity_filter_options', 20 ); // Activity Directory
remove_action( 'bp_member_activity_filter_options', 'wp_ulike_bp_activity_filter_options', 20 ); // Member's profile activity
remove_action( 'bp_group_activity_filter_options', 'wp_ulike_bp_activity_filter_options', 20 ); // Group's activity
}, 10 );