Skip to content

Instantly share code, notes, and snippets.

View orangerdev's full-sized avatar
🏠
busy mending broken

Ridwan Arifandi orangerdev

🏠
busy mending broken
View GitHub Profile
@orangerdev
orangerdev / task-1-companies-order.php
Last active October 10, 2017 07:23
TASK 1 - Ordering companies by sponsored and ranking
$args = [
'post_type' => 'company',
'posts_per_page' => 100,
'meta_query' => [
'relation' => 'AND',
[
'key' => 'sponsored',
'value' => [0,1]
'compare' => 'IN'
],
@orangerdev
orangerdev / task-2-wp-endpoint.php
Last active October 10, 2017 07:29
TASK 2 - WP Endpoint
<?php
namespace WP_Endpoint;
class Notifier
{
protected $valid = true;
protected $messages = [];
public $email = '';
@orangerdev
orangerdev / task-3-wp-cli.php
Last active October 10, 2017 07:32
TASK 3 - WPI CLI
<?php
namespace WP;
class CLI
{
/**
* Construction
*/
public function __construct()
@orangerdev
orangerdev / chunk-wp-query.php
Created October 13, 2017 07:14
Chunk WP_Query to get all posts
<?php
$found_posts = true; // Set as true
$offset = 0; // Set start post
$posts_per_page = 20; // Chunk for each 20 posts
while($found_posts) :
$query = new WP_Query([
'posts_per_page' => $posts_per_page,
'offset' => $offset
]);
@orangerdev
orangerdev / ridwan-wp-query.php
Last active January 4, 2018 05:33
Remodel WP_Query with chunked posts
<?php
namespace Ridwan;
class WP_Query
{
protected static $chunk = 10;
protected static $args = [];
protected static $posts = [];
protected static $respond = [];
@orangerdev
orangerdev / post-type.php
Last active January 4, 2018 04:57
Wordpress Chained Class to register post type
<?php
namespace sejoli;
Class PostType
{
protected static $labels = [];
protected static $args = [];
protected static $post_type = '';
protected static $valid = true;
protected static $exists = true;
@orangerdev
orangerdev / taxonomy.php
Created May 29, 2018 16:16
Library to register wordpress taxonomy easier
<?php
namespace JBSF\Admin;
class Taxonomy
{
private $label = [];
/**
* Construction
*/
@orangerdev
orangerdev / variation-price-label.php
Created June 26, 2018 09:39
Display variation value in variation dropdown (Woocommerce)
<?php
/**
* Plugin Name: WooCommerce - Display Variation Price in Dropdown
* Plugin URI: https://ridwanarifandi.com
* Description: Display price in variation dropdown
* Version: 1.0.0
* Author: Ridwan Arifandi
* Author URI: https://ridwanarifandi
* Text Domain: woocommerce
*
@orangerdev
orangerdev / override-woocommerce-templates.php
Created January 2, 2019 07:41
Function to override woocommerce template with your plugin templates
<?php
/**
* Return with custom template path
* Hooked via filter wc_get_template, priority 100
* @param string $located [description]
* @param string $template_name [description]
* @param string $args [description]
* @param string $template_path [description]
* @param string $default_path [description]
* @return string [description]
@orangerdev
orangerdev / wordpress-custom-endpoint.php
Created January 29, 2019 07:37
basic wordpress custom endpoint
<?php
/**
*
* Change 'custom-request' to anything you want
*
* Register custom rules
* Hooked via filter generate_rewrite_rules, priority 999
* @param Object $wp_rewrite
*/
function set_custom_rules($wp_rewrite)