Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 757
Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 757
Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 758
Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 758
Notice: require(): read of 13363 bytes failed with errno=12 Cannot allocate memory in /var/www/html/ticnews.com.br/web/wp-content/plugins/google-maps-easy/functions.php on line 44
Notice: require(): read of 13363 bytes failed with errno=12 Cannot allocate memory in /var/www/html/ticnews.com.br/web/wp-content/plugins/google-maps-easy/functions.php on line 44
register_deactivation_hook(GMP_DIR. DS. GMP_MAIN_FILE, array( 'utilsGmp', 'deactivatePlugin' ) );
add_action('init', array($this, 'connectLang'));
//$operationTime = microtime(true) - $startTime;
}
public function connectLang() {
load_plugin_textdomain(GMP_LANG_CODE, false, GMP_PLUG_NAME. '/languages/');
}
/**
* Check permissions for action in controller by $code and made corresponding action
* @param string $code Code of controller that need to be checked
* @param string $action Action that need to be checked
* @return bool true if ok, else - should exit from application
*/
public function checkPermissions($code, $action) {
if($this->havePermissions($code, $action))
return true;
else {
exit(_e('You have no permissions to view this page', GMP_LANG_CODE));
}
}
/**
* Check permissions for action in controller by $code
* @param string $code Code of controller that need to be checked
* @param string $action Action that need to be checked
* @return bool true if ok, else - false
*/
public function havePermissions($code, $action) {
$res = true;
$mod = $this->getModule($code);
$action = strtolower($action);
if($mod) {
$permissions = $mod->getController()->getPermissions();
if(!empty($permissions)) { // Special permissions
if(isset($permissions[GMP_METHODS])
&& !empty($permissions[GMP_METHODS])
) {
foreach($permissions[GMP_METHODS] as $method => $permissions) { // Make case-insensitive
$permissions[GMP_METHODS][strtolower($method)] = $permissions;
}
if(array_key_exists($action, $permissions[GMP_METHODS])) { // Permission for this method exists
$currentUserPosition = frameGmp::_()->getModule('user')->getCurrentUserPosition();
if((is_array($permissions[ GMP_METHODS ][ $action ]) && !in_array($currentUserPosition, $permissions[ GMP_METHODS ][ $action ]))
|| (!is_array($permissions[ GMP_METHODS ][ $action ]) && $permissions[GMP_METHODS][$action] != $currentUserPosition)
) {
$res = false;
}
}
}
if(isset($permissions[GMP_USERLEVELS])
&& !empty($permissions[GMP_USERLEVELS])
) {
$currentUserPosition = frameGmp::_()->getModule('user')->getCurrentUserPosition();
// For multi-sites network admin role is undefined, let's do this here
if(is_multisite() && is_admin() && is_super_admin()) {
$currentUserPosition = GMP_ADMIN;
}
foreach($permissions[GMP_USERLEVELS] as $userlevel => $methods) {
if(is_array($methods)) {
$lowerMethods = array_map('strtolower', $methods); // Make case-insensitive
if(in_array($action, $lowerMethods)) { // Permission for this method exists
if($currentUserPosition != $userlevel)
$res = false;
break;
}
} else {
$lowerMethod = strtolower($methods); // Make case-insensitive
if($lowerMethod == $action) { // Permission for this method exists
if($currentUserPosition != $userlevel)
$res = false;
break;
}
}
}
}
}
}
return $res;
}
public function getRes() {
return $this->_res;
}
public function execAfterWpInit() {
$this->_doExec();
}
/**
* Check if method for module require some special permission. We can detect users permissions only after wp init action was done.
*/
protected function _execOnlyAfterWpInit() {
$res = false;
$mod = $this->getModule( $this->_mod );
$action = strtolower( $this->_action );
if($mod) {
$permissions = $mod->getController()->getPermissions();
if(!empty($permissions)) { // Special permissions
if(isset($permissions[GMP_METHODS])
&& !empty($permissions[GMP_METHODS])
) {
foreach($permissions[GMP_METHODS] as $method => $permissions) { // Make case-insensitive
$permissions[GMP_METHODS][strtolower($method)] = $permissions;
}
if(array_key_exists($action, $permissions[GMP_METHODS])) { // Permission for this method exists
$res = true;
}
}
if(isset($permissions[GMP_USERLEVELS])
&& !empty($permissions[GMP_USERLEVELS])
) {
$res = true;
}
}
}
return $res;
}
protected function _execModules() {
if($this->_mod) {
// If module exist and is active
$mod = $this->getModule($this->_mod);
if($mod && $this->_action) {
if($this->_execOnlyAfterWpInit()) {
add_action('init', array($this, 'execAfterWpInit'));
} else {
$this->_doExec();
}
}
}
}
protected function _doExec() {
$mod = $this->getModule($this->_mod);
if($mod && $this->checkPermissions($this->_mod, $this->_action)) {
switch(reqGmp::getVar('reqType')) {
case 'ajax':
add_action('wp_ajax_'. $this->_action, array($mod->getController(), $this->_action));
add_action('wp_ajax_nopriv_'. $this->_action, array($mod->getController(), $this->_action));
break;
default:
$this->_res = $mod->exec($this->_action);
break;
}
}
}
protected function _extractTables($tablesDir = GMP_TABLES_DIR) {
$mDirHandle = opendir($tablesDir);
while(($file = readdir($mDirHandle)) !== false) {
if(is_file($tablesDir. $file) && $file != '.' && $file != '..' && strpos($file, '.php')) {
$this->_extractTable( str_replace('.php', '', $file), $tablesDir );
}
}
}
protected function _extractTable($tableName, $tablesDir = GMP_TABLES_DIR) {
importClassGmp('noClassNameHere', $tablesDir. $tableName. '.php');
$this->_tables[$tableName] = tableGmp::_($tableName);
}
/**
* public alias for _extractTables method
* @see _extractTables
*/
public function extractTables($tablesDir) {
if(!empty($tablesDir))
$this->_extractTables($tablesDir);
}
public function exec() {
/**
* @deprecated
*/
/*if(!empty($this->_modules)) {
foreach($this->_modules as $mod) {
$mod->exec();
}
}*/
}
public function getTables () {
return $this->_tables;
}
/**
* Return table by name
* @param string $tableName table name in database
* @return object table
* @example frameGmp::_()->getTable('products')->getAll()
*/
public function getTable($tableName) {
if(empty($this->_tables[$tableName])) {
$this->_extractTable($tableName);
}
return $this->_tables[$tableName];
}
public function getModules($filter = array()) {
$res = array();
if(empty($filter))
$res = $this->_modules;
else {
foreach($this->_modules as $code => $mod) {
if(isset($filter['type'])) {
if(is_numeric($filter['type']) && $filter['type'] == $mod->getTypeID())
$res[$code] = $mod;
elseif($filter['type'] == $mod->getType())
$res[$code] = $mod;
}
}
}
return $res;
}
public function getModule($code) {
return (isset($this->_modules[$code]) ? $this->_modules[$code] : NULL);
}
public function inPlugin() {
return $this->_inPlugin;
}
/**
* Push data to script array to use it all in addScripts method
* @see wp_enqueue_script definition
*/
public function addScript($handle, $src = '', $deps = array(), $ver = false, $in_footer = false, $vars = array()) {
$src = empty($src) ? $src : uriGmp::_($src);
if(!$ver)
$ver = GMP_VERSION_PLUGIN;
if($this->_scriptsInitialized) {
wp_enqueue_script($handle, $src, $deps, $ver, $in_footer);
} else {
$this->_scripts[] = array(
'handle' => $handle,
'src' => $src,
'deps' => $deps,
'ver' => $ver,
'in_footer' => $in_footer,
'vars' => $vars
);
}
}
/**
* Add all scripts from _scripts array to worgmpess
*/
public function addScripts() {
if(!empty($this->_scripts)) {
foreach($this->_scripts as $s) {
wp_enqueue_script($s['handle'], $s['src'], $s['deps'], $s['ver'], $s['in_footer']);
if($s['vars'] || isset($this->_scriptsVars[$s['handle']])) {
$vars = array();
if($s['vars'])
$vars = $s['vars'];
if($this->_scriptsVars[$s['handle']])
$vars = array_merge($vars, $this->_scriptsVars[$s['handle']]);
if($vars) {
foreach($vars as $k => $v) {
wp_localize_script($s['handle'], $k, $v);
}
}
}
}
}
$this->_scriptsInitialized = true;
}
public function addJSVar($script, $name, $val) {
if($this->_scriptsInitialized) {
wp_localize_script($script, $name, $val);
} else {
$this->_scriptsVars[$script][$name] = $val;
}
}
public function addStyle($handle, $src = false, $deps = array(), $ver = false, $media = 'all') {
$src = empty($src) ? $src : uriGmp::_($src);
if(!$ver)
$ver = GMP_VERSION_PLUGIN;
if($this->_stylesInitialized) {
wp_enqueue_style($handle, $src, $deps, $ver, $media);
} else {
$this->_styles[] = array(
'handle' => $handle,
'src' => $src,
'deps' => $deps,
'ver' => $ver,
'media' => $media
);
}
}
public function addStyles() {
if(!empty($this->_styles)) {
foreach($this->_styles as $s) {
wp_enqueue_style($s['handle'], $s['src'], $s['deps'], $s['ver'], $s['media']);
}
}
$this->_stylesInitialized = true;
}
public function getScripts() {
return $this->_scripts;
}
public function getStyles() {
return $this->_styles;
}
public function setScriptsInitialized($state) {
$this->_scriptsInitialized = $state;
}
public function setStylesInitialized($state) {
$this->_stylesInitialized = $state;
}
public function getJSVars() {
return $this->_scriptsVars;
}
//Very interesting thing going here.............
public function loadPlugins() {
require_once(ABSPATH. 'wp-includes/pluggable.php');
}
public function loadWPSettings() {
require_once(ABSPATH. 'wp-settings.php');
}
public function loadLocale() {
require_once(ABSPATH. 'wp-includes/locale.php');
}
public function moduleActive($code) {
return isset($this->_modules[$code]);
}
public function moduleExists($code) {
if($this->moduleActive($code))
return true;
return isset($this->_allModules[$code]);
}
public function isTplEditor() {
$tplEditor = reqGmp::getVar('tplEditor');
return (bool) $tplEditor;
}
/**
* This is custom method for each plugin and should be modified if you create copy from this instance.
*/
public function isAdminPlugOptsPage() {
$page = reqGmp::getVar('page');
if(is_admin() && strpos($page, frameGmp::_()->getModule('adminmenu')->getMainSlug()) !== false)
return true;
return false;
}
public function isAdminPlugPage() {
if($this->isAdminPlugOptsPage()) {
return true;
}
return false;
}
public function licenseDeactivated() {
return (!$this->getModule('license') && $this->moduleExists('license'));
}
public function savePluginActivationErrors() {
update_option(GMP_CODE. '_plugin_activation_errors', ob_get_contents());
}
public function getActivationErrors() {
return get_option(GMP_CODE. '_plugin_activation_errors');
}
public function getPluginUrl() {
return plugins_url('', dirname(__FILE__));
}
}