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 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-pro.php
Last active December 11, 2023 14:36
add custom fields to register form
<?php
function wp_ulike_pro_custom_after_signup_process( &$args ){
// Get current user id
$meta_args = array();
$meta_args['phone'] = ! empty( $_POST['phone'] ) ? $_POST['phone'] : null;
$meta_args['user-role'] = ! empty( $_POST['user-role'] ) ? array( $_POST['user-role'] ) : null;
foreach ($meta_args as $key => $value) {
update_user_meta( $args->data['user_id'], $key, $value );
@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-pro.php
Last active March 10, 2023 12:24
Add new password field inside wp ulike edit account & signup forms
<?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.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
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 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-pro.php
Last active June 27, 2022 09:07
Filter posts by like amount in elementor post widget
<?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 = [];
}