This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, install all of the things | |
sudo su | |
apt-get update | |
apt-get install nginx | |
/etc/init.d/nginx start | |
apt-get install python-dev | |
apt-get install python-pip | |
apt-get install libjpeg-dev libpng-dev libtiff-dev libjasper-dev libgtk2.0-dev python-numpy python-pycurl libwebp-dev python-opencv libjpeg-progs | |
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress\ReadingTime; | |
class Database { | |
public function __construct(){ | |
global $wpdb; | |
$this->wpdb = $wpdb; | |
$this->table = $this->wpdb->prefix."posts_reading_time"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg/WordPress/ReadingTime; | |
add_filter('posts_where', function($where, $wp_query){ | |
$readingTime = $wp_query->get("reading_time", false); | |
if(is_array($readingTime) && isset($readingTime["compare"]) && isset($readingTime["value"]) ){ | |
$db = new Database(); | |
$value = intval($readingTime["value"]); | |
$compare = $readingTime["compare"]; // should be sanitized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress\Schedule; | |
const SCHEDULE_ACTION = "public_function_org_schedule"; | |
function init(){ | |
if(!wp_next_scheduled(SCHEDULE_ACTION)){ | |
wp_schedule_event(time(), 'hourly', SCHEDULE_ACTION); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress\Gutenberg; | |
const HANDLE = "my-gutenberg-script"; | |
add_action( 'enqueue_block_editor_assets', function () { | |
wp_enqueue_script( | |
HANDLE, | |
plugin_dir_url(__FILE__) . "/js/my-gutenberg-script.js", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress\Gutenberg; | |
const HANDLE = "my-gutenberg-script"; | |
add_action( 'enqueue_block_editor_assets', function () { | |
$info = include plugin_dir_path(__FILE__) . "/js/my-gutenberg-script.asset.php"; | |
wp_enqueue_script( | |
HANDLE, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress; | |
class Repsitory { | |
public function __construct($service){ | |
$this->service = $service; // service api implementation class | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress; | |
class Templates { | |
private $theme_dir = "/my-plugin-templates/"; | |
public function get_template_path($template){ | |
if ( $overridden_template = locate_template( $this->theme_dir.$template ) ) { | |
return $overridden_template; | |
} | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress; | |
class Templates { | |
private $theme_dir = "/my-plugin-templates/"; | |
public function get_template_path($template){ | |
$path = $this->theme_dir.$template; | |
if( is_file( get_template_directory().$path)){ | |
return get_template_directory().$path; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PublicFunctionOrg\WordPress; | |
class Templates { | |
public function get_template_path($template){ | |
$paths = apply_filters("my_plugin_add_template_paths", []); | |
foreach ($paths as $path){ | |
if(is_file("$path/$template")){ | |
return "$path/$template"; | |
} | |
} |
OlderNewer