Skip to content

Instantly share code, notes, and snippets.

View Mosharush's full-sized avatar
👨‍💻
Code. Sleep. Repeat.

Moshe Harush Mosharush

👨‍💻
Code. Sleep. Repeat.
View GitHub Profile
@Mosharush
Mosharush / makewp.php
Created October 30, 2017 13:02
Get latest Wordpress archive to server and extract files
<?php
// Function to remove folders and files
function rrmdir($dir) {
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file)
if ($file != "." && $file != "..") rrmdir("$dir/$file");
rmdir($dir);
}
else if (file_exists($dir)) unlink($dir);
@Mosharush
Mosharush / functions.php
Last active November 29, 2017 06:32
Fake Wordpress filter integartion for allow add page template via plugins
<?php
// Spacial Hook! : Add cart page template for cart on admin page options
add_filter( 'theme_page_templates', 'add_cart_page_template_option_select' );
add_filter( 'page_template', 'add_cart_page_template_to_theme', 10, 3 );
function add_cart_page_template_option_select( $post_templates ) {
$post_templates[ 'some-page-name-non-exist-or-uniqe.php' ] = __( 'Page Template Name', 'text-domain' );
return $post_templates;
}
function add_cart_page_template_to_theme( $template, $type, $templates ) {
if( $type === 'page' && $templates[0] === 'some-page-name-non-exist-or-uniqe.php' ) {
@Mosharush
Mosharush / options_ui.php
Created December 7, 2017 06:41
HOTFIX - Rock Theme Wordpress, Azoom theme - Theme options not updates bug
<?php
function rockthemes_to_get_option_length( $array = array() ) {
if ( empty( $array ) ) {
return 0;
}
$array_count = 0;
@Mosharush
Mosharush / script.js
Last active December 27, 2017 03:16
Auto ajax function
$ = jQuery;
var ws_ajax_manager = function(){
// settings
this.config = {
content_selector: '.fl-page-content',
loader_src: 'https://loading.io/spinners/double-ring/lg.double-ring-spinner.gif',
};
@Mosharush
Mosharush / axios-middleware.js
Last active October 18, 2018 21:10
Nuxt.js 2.2.0 - Fix Error Cannot stringify arbitrary non-POJOs
/**
* plugins/axios-middleware.js
*/
import axios from 'axios';
axios.interceptors.response.use(response => {
if( typeof response.data === 'object' && response.data.constructor !== Array ) {
response.data = Object.assign({}, response.data);
}
@Mosharush
Mosharush / find-out-admin-path.js
Last active November 30, 2018 23:05
Quick way to find out admin panel address
fetch('/robots.txt').then(function(data){
return data.text();
}).then(function(text) {
const paths = [
'?q=user',
'/wp-admin',
'/administrator',
'/cms',
'/admin',
];
@Mosharush
Mosharush / bookmark
Created December 25, 2018 23:19
Show input password test for auto fill password
javascript:const inputs=document.querySelectorAll('input[type=password]');inputs.forEach((input)=>{input.type='text';setTimeout(()=>{input.type='password';},5000);});
@Mosharush
Mosharush / 3d.css
Created January 4, 2019 01:10
Harlem Shake
html {
transform: translateZ(-107px);
transform-style: preserve-3d;
perspective: 532px;
}
body {
transform: translateZ(-94em) rotateX(30deg) rotateZ(-0deg);
}
@Mosharush
Mosharush / auto-placeholder-images.php
Created October 17, 2019 10:40
This plugin resolve broken layout when we work on local machine without all uploaded images up to date. Will replace the images with image placeholder via placeholder.com
<?php
/**
* @package Auto_Placeholder_Images
* @version 1.0.0
*/
/*
Plugin Name: Auto Placeholder For Broken Images
Plugin URI: https://www.webstorm.co.il/css-live-reload/
Description: **FOR DEV USE ONLY** This plugin resolve broken layout when we work on local machine without all uploaded images up to date. Will replace the images with image placeholder via placeholder.com
Author: Moshe Harush
@Mosharush
Mosharush / tsconfig.js
Created December 19, 2019 20:09
TypeScript config example
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"removeComments": true,
"preserveConstEnums": true,
"outDir": "build",
"allowJs": true,
"target": "es2015",
"sourceMap": true,