Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Asad Shahbaz Artisan-Asad

🎯
Focusing
Block or report user

Report or block Artisan-Asad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Artisan-Asad
Artisan-Asad / create-admin-user.php
Created Sep 28, 2019 — forked from abdulwahab610/create-admin-user.php
Create a new admin user in WordPress through code. You just need to change the variables and drop the file in the mu-plugins directory or add the following code in active theme's functions.php, then reload the homepage in WordPress. The new user will be created. Remove the file/code after that.
View create-admin-user.php
<?php
add_action( 'init', 'aw610_create_user' );
function aw610_create_user() {
$username = 'admin';
$password = 'password';
$email_address = 'email@domain.com';
if ( ! username_exists( $username ) ) {
View Sort multidimensional array in php
public static function sort_array( $array ) {
usort($array, array( 'self', 'sort_fallback' ) );
return $array;
}
private static function sort_fallback( $a, $b ) {
return $b[1] - $a[1];
}
View Offset minus selected section
$('html, body').animate({
scrollTop: $('#filter-location-name').offset().top - $('#top-header').outerHeight() - $('#main-header').outerHeight() - 10
}, 1000);
@Artisan-Asad
Artisan-Asad / divi.css
Created Nov 22, 2018
Divi full width pages with no sidebar
View divi.css
/*** Take out the divider line between content and sidebar ***/
#main-content .container:before {
background: none;
}
/*** Expand the content area to fullwidth ***/
@media (min-width: 981px){
#left-area {
width: 100% !important;
max-width: 800px;
@Artisan-Asad
Artisan-Asad / scroll-shadow.js
Created Aug 18, 2018
Give shadow to upper element on scroll
View scroll-shadow.js
$('.scroll-container').on('scroll',function(e) {
var currentScrollPosition= $('.scroll-container').scrollTop() + $('.scroll-container').height();
if (currentScrollPosition == $('.scroll-container').height()) {
$('.fe-mdm-favorites').removeClass('shadow-bottom');
} else {
$('.fe-mdm-favorites').addClass('shadow-bottom');
}
});
@Artisan-Asad
Artisan-Asad / attachment_id.php
Created Jul 24, 2018
WordPress find attachment id from URL
View attachment_id.php
function get_attachment_id_from_url( $attachment_url = '' ) {
global $wpdb;
$attachment_id = false;
// If there is no url, return.
if ( '' == $attachment_url )
return;
// Get the upload directory paths
@Artisan-Asad
Artisan-Asad / varify_youtube.php
Last active Jul 24, 2018
Verify youtube link in PHP application
View varify_youtube.php
function get_youtube_id( $video_url ){
if( (preg_match('/http:\/\/(www\.)*youtube\.com\/.*/',$video_url)) || (preg_match('/http:\/\/(www\.)*youtu\.be\/.*/',$video_url)) )
{
$video_id = ( preg_match( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $video_url, $match ) ) ? $match[1] : false;
return $video_id;
} else
{
return false;
}
@Artisan-Asad
Artisan-Asad / gist:47b9f29422c58d2fd76923117ff70975
Created Jul 19, 2018
Regular expression to test if a URL is a WordPress plugin repository URL
View gist:47b9f29422c58d2fd76923117ff70975
'|^http[s]?://wordpress\.org/(?:extend/)?plugins/|'
@Artisan-Asad
Artisan-Asad / gist:64abd663e41e91c98fbc40bf95e8aa75
Created Jul 19, 2018
Arbitrary regular expression to test if a string starts with a URL
You can’t perform that action at this time.