| Server IP : 68.178.247.200 / Your IP : 216.73.217.50 Web Server : Apache System : Linux p3plzcpnl489463.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64 User : x9dppmxs4rgd ( 8559391) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/x9dppmxs4rgd/www/wp-content/plugins/grace-church-utils/ |
Upload File : |
<?php
/*
Plugin Name: Grace Church Utilities
Plugin URI: http://themerex.net
Description: Utils for files, directories, post type and taxonomies manipulations
Version: 2.0
Author: ThemeREX
Author URI: http://themerex.net
*/
// Don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
// Current version
if ( ! defined( 'TRX_UTILS_VERSION' ) ) {
define( 'TRX_UTILS_VERSION', '2.0' );
}
/* Types and taxonomies
------------------------------------------------------ */
// Register theme required types and taxes
if (!function_exists('grace_church_require_data')) {
function grace_church_require_data($type, $name, $args) {
if ($type == 'taxonomy')
register_taxonomy($name, $args['post_type'], $args);
else
register_post_type($name, $args);
}
}
/* Twitter API
------------------------------------------------------ */
if (!function_exists('trx_utils_twitter_acquire_data')) {
function trx_utils_twitter_acquire_data($cfg) {
if (empty($cfg['mode'])) $cfg['mode'] = 'user_timeline';
$data = get_transient("twitter_data_".($cfg['mode']));
if (!$data) {
require_once( plugin_dir_path( __FILE__ ) . 'lib/tmhOAuth/tmhOAuth.php' );
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $cfg['consumer_key'],
'consumer_secret' => $cfg['consumer_secret'],
'token' => $cfg['token'],
'secret' => $cfg['secret']
));
$code = $tmhOAuth->user_request(array(
'url' => $tmhOAuth->url(trx_utils_twitter_mode_url($cfg['mode']))
));
if ($code == 200) {
$data = json_decode($tmhOAuth->response['response'], true);
if (isset($data['status'])) {
$code = $tmhOAuth->user_request(array(
'url' => $tmhOAuth->url(trx_utils_twitter_mode_url($cfg['oembed'])),
'params' => array(
'id' => $data['status']['id_str']
)
));
if ($code == 200)
$data = json_decode($tmhOAuth->response['response'], true);
}
set_transient("twitter_data_".($cfg['mode']), $data, 60*60);
}
} else if (!is_array($data) && substr($data, 0, 2)=='a:') {
$data = unserialize($data);
}
return $data;
}
}
if (!function_exists('trx_utils_twitter_mode_url')) {
function trx_utils_twitter_mode_url($mode) {
$url = '/1.1/statuses/';
if ($mode == 'user_timeline')
$url .= $mode;
else if ($mode == 'home_timeline')
$url .= $mode;
return $url;
}
}
/* Shortcodes
------------------------------------------------------ */
// Register theme required shortcodes
if (!function_exists('grace_church_require_shortcode')) {
function grace_church_require_shortcode($name, $callback) {
add_shortcode($name, $callback);
}
}
/* Twitter API
------------------------------------------------------ */
if (!function_exists('grace_church_twitter_acquire_data')) {
function grace_church_twitter_acquire_data($cfg) {
if (empty($cfg['mode'])) $cfg['mode'] = 'user_timeline';
$data = get_transient("twitter_data_".($cfg['mode']));
if (!$data) {
require_once( plugin_dir_path( __FILE__ ) . 'lib/tmhOAuth/tmhOAuth.php' );
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $cfg['consumer_key'],
'consumer_secret' => $cfg['consumer_secret'],
'token' => $cfg['token'],
'secret' => $cfg['secret']
));
$code = $tmhOAuth->user_request(array(
'url' => $tmhOAuth->url(grace_church_twitter_mode_url($cfg['mode']))
));
if ($code == 200) {
$data = json_decode($tmhOAuth->response['response'], true);
if (isset($data['status'])) {
$code = $tmhOAuth->user_request(array(
'url' => $tmhOAuth->url(grace_church_twitter_mode_url($cfg['oembed'])),
'params' => array(
'id' => $data['status']['id_str']
)
));
if ($code == 200)
$data = json_decode($tmhOAuth->response['response'], true);
}
set_transient("twitter_data_".($cfg['mode']), $data, 60*60);
}
} else if (!is_array($data) && substr($data, 0, 2)=='a:') {
$data = unserialize($data);
}
return $data;
}
}
if (!function_exists('grace_church_twitter_mode_url')) {
function grace_church_twitter_mode_url($mode) {
$url = '/1.1/statuses/';
if ($mode == 'user_timeline')
$url .= $mode;
else if ($mode == 'home_timeline')
$url .= $mode;
return $url;
}
}
/* LESS compilers
------------------------------------------------------ */
// Compile less-files
if (!function_exists('grace_church_less_compiler')) {
function grace_church_less_compiler($list, $opt) {
$success = true;
// Load and create LESS Parser
if ($opt['compiler'] == 'lessc') {
// 1: Compiler Lessc
require_once( plugin_dir_path( __FILE__ ) . 'lib/lessc/lessc.inc.php' );
} else {
// 2: Compiler Less
require_once( plugin_dir_path( __FILE__ ) . 'lib/less/Less.php' );
}
foreach($list as $file) {
if (empty($file) || !file_exists($file)) continue;
$file_css = substr_replace($file , 'css', strrpos($file , '.') + 1);
// Check if time of .css file after .less - skip current .less
if (!empty($opt['check_time']) && file_exists($file_css)) {
$css_time = filemtime($file_css);
if ($css_time >= filemtime($file) && ($opt['utils_time']==0 || $css_time > $opt['utils_time'])) continue;
}
// Compile current .less file
try {
// Create Parser
if ($opt['compiler'] == 'lessc') {
$parser = new lessc;
//$parser->registerFunction("replace", "grace_church_less_func_replace");
if ($opt['compressed']) $parser->setFormatter("compressed");
} else {
if ($opt['compressed'])
$args = array('compress' => true);
else {
$args = array('compress' => false);
if ($opt['map'] != 'no') {
$args['sourceMap'] = true;
if ($opt['map'] == 'external') {
$args['sourceMapWriteTo'] = $file.'.map';
$args['sourceMapURL'] = str_replace(
array(get_template_directory(), get_stylesheet_directory()),
array(get_template_directory_uri(), get_stylesheet_directory_uri()),
$file) . '.map';
}
}
}
$parser = new Less_Parser($args);
}
// Parse main file
$css = '';
if ($opt['map'] != 'no') {
// Parse main file
$parser->parseFile( $file, '');
// Parse less utils
if (is_array($opt['utils']) && count($opt['utils']) > 0) {
foreach($opt['utils'] as $utility) {
$parser->parseFile( $utility, '');
}
}
// Parse less vars (from Theme Options)
if (!empty($opt['vars'])) {
$parser->parse($opt['vars']);
}
// Get compiled CSS code
$css = $parser->getCss();
// Reset LESS engine
$parser->Reset();
} else if (($text = file_get_contents($file))!='') {
$parts = $opt['separator'] != '' ? explode($opt['separator'], $text) : array($text);
for ($i=0; $i<count($parts); $i++) {
$text = $parts[$i]
. (!empty($opt['utils']) ? $opt['utils'] : '') // Add less utils
. (!empty($opt['vars']) ? $opt['vars'] : ''); // Add less vars (from Theme Options)
// Get compiled CSS code
if ($opt['compiler']=='lessc')
$css .= $parser->compile($text);
else {
$parser->parse($text);
$css .= $parser->getCss();
$parser->Reset();
}
}
}
if ($css) {
if ($opt['map']=='no') {
// If it main theme style - append CSS after header comments
if ($file == get_template_directory(). '/style.less') {
// Append to the main Theme Style CSS
$theme_css = file_get_contents( get_template_directory() . '/style.css' );
$css = substr($theme_css, 0, strpos($theme_css, '*/')+2) . "\n\n" . $css;
} else {
$css = "/*"
. "\n"
. __('Attention! Do not modify this .css-file!', 'grace-church')
. "\n"
. __('Please, make all necessary changes in the corresponding .less-file!', 'grace-church')
. "\n"
. "*/"
. "\n"
. '@charset "utf-8";'
. "\n\n"
. $css;
}
}
// Save compiled CSS
file_put_contents( $file_css, $css);
}
} catch (Exception $e) {
if (function_exists('dfl')) dfl($e->getMessage());
$success = false;
}
}
return $success;
}
}
// LESS function
/*
if (!function_exists('grace_church_less_func_replace')) {
function grace_church_less_func_replace($arg) {
return $arg;
}
}
*/
?>