Skip to content

Instantly share code, notes, and snippets.

View wordpress-lab's full-sized avatar

Wordpress Blog wordpress-lab

  • Dhaka
View GitHub Profile
/**
* Register a meta box using a class.
*/
class WPDocs_Custom_Meta_Box {
/**
* Constructor.
*/
public function __construct() {
if ( is_admin() ) {
@wordpress-lab
wordpress-lab / custom-control-init.php
Created August 13, 2019 13:41 — forked from iqbalrony/custom-control-init.php
Create Elementor Custom Control.
<?php
namespace ElementorControls;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
class Elementor_Custom_Controls {
public function includes() {
require_once(plugin_dir_path(__FILE__).'inc/elementor/image-selector-control.php');
}
@wordpress-lab
wordpress-lab / custom-css.php
Created August 13, 2019 13:41 — forked from iqbalrony/custom-css.php
How to add custom css control with elementor free version.
<?php
use Elementor\Controls_Manager;
use Elementor\Element_Base;
use Elementor\Core\Files\CSS\Post;
use Elementor\Core\DynamicTags\Dynamic_CSS;
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
<?php
// Fetching JSON
$req_url = 'https://api.exchangerate-api.com/v4/latest/USD';
//$req_url = 'https://api.exchangerate-api.com/v4/latest/EUR';
$response_json = file_get_contents($req_url);
// Continuing if we got a result
if(false !== $response_json) {
// Try/catch for json_decode operation
<?php
$data = array('slug' => 'rest_insert' , 'title' => 'wp remote API insert wp update 1817' , 'content' => 'The content of our stuff update post 2', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$id= 1827;
$args = array(
'headers' => array(
//'Authorization' => 'Bearer ' . $token
'Authorization' => 'Basic ' . base64_encode( $username . ':' . $password ),
'Content-Type' => 'application/json',
),
@wordpress-lab
wordpress-lab / crud-create
Last active July 15, 2019 19:17
crud-php
<?php
$username = 'redeye007';
$password = 'redeye123';
$id= 1780;
// the standard end point for posts in an initialised Curl
$process = curl_init('http://wordpress-300829-921065.cloudwaysapps.com/wp-json/wp/v2/posts');
// create an array of data to use, this is basic - see other examples for more complex inserts
$data = array('slug' => 'rest_insert' , 'title' => 'new REST API insert update 258' , 'content' => ' newThe content of our stuff update post 2sdsd', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
@wordpress-lab
wordpress-lab / Readme.md
Created April 14, 2019 07:15 — forked from Golpha/Readme.md
PHP Object-hacks without Reflections: Injectors and Closure Binding References

PHP Object-hacks without Reflections

Sometimes it is needed to manipulate private and protected properties of instances. The common way to do this is to manipule the visibility of the targeted properties using class reflection, but there is a more memory and performance efficient way to accomplish this task.

Reading and writing private and protected properties using injectors

At first injectors are not standardized nor described along design patterns, i choose Injectors as the name for this mechanic because of their major usage. The explicit technical name could be: IO-Adapters for invisible properties. Injectors do use closure binding with a explicit class scope. So, whatever you want to modify does require knowledge about the implementation details of the targeted parameters, as you should have when directly using closure binding.

The Injector class
<?php
// Add a new interval of a week
// See http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules
add_filter( 'cron_schedules', 'myprefix_add_weekly_cron_schedule' );
function myprefix_add_weekly_cron_schedule( $schedules ) {
$schedules['weekly'] = array(
'interval' => 604800, // 1 week in seconds
'display' => __( 'Once Weekly' ),
);
$array = array(
array(
"type" => "a",
"value" => 1
),
array(
"type" => "a",
"value" => 2
),
array(
@wordpress-lab
wordpress-lab / dynamicform.html
Created October 13, 2017 08:43
dynamic form
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Latest compiled and minified CSS -->