Skip to content

Instantly share code, notes, and snippets.

View webdevid's full-sized avatar
🎯
Focusing

dodi hidayatullah webdevid

🎯
Focusing
View GitHub Profile
@webdevid
webdevid / my-pattern-library
Created February 26, 2022 12:39 — forked from ndiego/my-pattern-library
My Pattern Library
<?php
/**
* Plugin Name: My Pattern Library
* Description: A simple library of block patterns.
* Version: 0.1.0
* Requires at least: 5.8
* Requires PHP: 7.0
* Author: Your Name
* License: GPL v2 or later
* Text Domain: my-pattern-library
@webdevid
webdevid / strip_word_html.php
Created January 17, 2022 20:56 — forked from dave1010/strip_word_html.php
Strip MS Word HTML. From php.net
<?php
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
{
mb_regex_encoding('UTF-8');
//replace MS special characters first
$search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
$replace = array('\'', '\'', '"', '"', '-');
$text = preg_replace($search, $replace, $text);
//make sure _all_ html entities are converted to the plain ascii equivalents - it appears
//in some MS headers, some html entities are encoded and some aren't
@webdevid
webdevid / fix-wordpress-permissions.sh
Created July 17, 2021 16:05 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@webdevid
webdevid / block-dace-with-pagination.php
Created December 11, 2020 03:51
contoh block dace dengan pagination
/**
* Block Dace update
* 8/20/2019, 10:44:12 AM
*/
Block::make( __( 'Block Dace List' ) )
->add_tab( __( 'Block Dace List' ), array(
Field::make( 'text', 'block_title', __( 'Title' ) )->set_default_value('Open position'),
Field::make( 'rich_text', 'block_desc', __( 'Description' ) ),
Field::make( 'select', 'block_column', __( 'Column' ) )
->set_options( array(
@webdevid
webdevid / yoast_seo_opengraph_change_image_size.php
Created April 25, 2020 04:36 — forked from amboutwe/yoast_seo_opengraph_change_image_size.php
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 24 2019 using Yoast SEO 11.2.1 on WordPress 5.2.1
*/
add_filter( 'wpseo_opengraph_image_size', 'yoast_seo_opengraph_change_image_size' );
function yoast_seo_opengraph_change_image_size( $string ) {
@webdevid
webdevid / _bem-builder.scss
Created February 28, 2020 09:47 — forked from iamravenous/_bem-builder.scss
Sass BEM Mixins
@mixin element($name) {
@at-root #{&}__#{$name}{
@content;
}
}
@mixin modifier($name) {
@at-root #{&}--#{$name} {
@content;
}
@webdevid
webdevid / Form.class.php
Created October 2, 2019 06:59 — forked from kalinchernev/Form.class.php
Basic class to build a form from an array
<?php
/**
* Form Class
*
* Responsible for building forms
*
* @param array $elements renderable array containing form elements
*
* @return void
@webdevid
webdevid / ContactForm.md
Created October 27, 2018 12:36 — forked from patotoma/ContactForm.md
secure php contact form

Secured PHP Contact Form

<?php
  if(isset($_POST['submit'])){
    $name = htmlspecialchars(stripslashes(trim($_POST['name'])));
    $subject = htmlspecialchars(stripslashes(trim($_POST['subject'])));
    $email = htmlspecialchars(stripslashes(trim($_POST['email'])));
    $message = htmlspecialchars(stripslashes(trim($_POST['message'])));
    if(!preg_match("/^[A-Za-z .'-]+$/", $name)){
@webdevid
webdevid / simple_php_pagination.php
Created September 7, 2018 04:22 — forked from Stichoza/simple_php_pagination.php
Simple PHP Pagination (one function)
<?php
/**
*
* Simple PHP Pagination
*
* @author Stichoza
* @link http://stichoza.com/
* @email admin@stichoza.com
* @version 1.0
@webdevid
webdevid / spintax.php
Created August 8, 2018 12:30 — forked from irazasyed/spintax.php
PHP: Text Spinner Class - Nested spinning supported.
<?PHP
/**
* Spintax - A helper class to process Spintax strings.
* @name Spintax
* @author Jason Davis - https://www.codedevelopr.com/
* Tutorial: https://www.codedevelopr.com/articles/php-spintax-class/
*/
class Spintax
{
public function process($text)