function meAnjanWqg_DisabledNotice() { echo '<div class="error"><p>' . esc_html__(ME_ANJAN_PLUGIN_WQG_NICE_NAME . ' is now deactivated, because it requires PHP version ' . ME_ANJAN_PLUGIN_WQG_MIN_PHP_VERSION . ' or higher, but you PHP version is ' . PHP_VERSION . '!', 'my-plugin') . '</p></div>'; } /* Was plugin already activated? deactivate it! */ add_action('admin_init', 'meAnjanWqg_DeactivatePlugin'); function meAnjanWqg_DeactivatePlugin() { deactivate_plugins(plugin_basename(__FILE__)); } return; } /* plugin base file path */ define('ME_ANJAN_PLUGIN_WQG_BASE_FILE_PATH', plugin_basename(__FILE__)); /* Plugin dir root */ define('ME_ANJAN_PLUGIN_WQG_DIR', plugin_dir_path(__FILE__)); /* Plugin dir url */ define('ME_ANJAN_WQG_URL_ROOT', plugin_dir_url(__FILE__)); /* Auto Load Classes */ function meAnjanPluginWqgAutoLoader($className) { $classDir = ME_ANJAN_PLUGIN_WQG_DIR . '/includes/classes/'; $fileName = $classDir . 'class.' . $className . '.php'; if (file_exists($fileName)) { require_once $fileName; } } spl_autoload_register('meAnjanPluginWqgAutoLoader'); /* Start the process */ meAnjanWqg_Main::getInstance()->init();
/** * Prepares the data to be passed to javascript * * @return array * */ private function prepareJsData() { $main = meAnjanWqg_Main::getInstance(); $jsData = array('idPrefix' => $main->getConfig('idPrefix'), 'ajax_url' => array('form_generate' => meAnjanWqg_Utils::wpAjaxUrl(self::AJAX_ACTION_GENERATE_CODE), 'author_id_autocomplete' => meAnjanWqg_Utils::wpAjaxUrl(self::AJAX_ACTION_AUTHOR_ID_AUTOCOMLETE), 'author_name_autocomplete' => meAnjanWqg_Utils::wpAjaxUrl(self::AJAX_ACTION_AUTHOR_NAME_AUTOCOMLETE), 'taxonomy_terms' => meAnjanWqg_Utils::wpAjaxUrl(self::AJAX_ACTION_TAXONOMY_TERMS), 'data_preview' => meAnjanWqg_Utils::wpAjaxUrl(self::AJAX_ACTION_DATA_PREVIEW), 'post_list' => meAnjanWqg_Utils::wpAjaxUrl(self::AJAX_ACTION_POST_LIST)), 'codeMirrorTheme' => self::CODEMIRROR_THEME, 'html_ids' => $main->getConfig('html/ids'), 'taxonomies' => meAnjanWqg_Taxonomies::getTaxonomies(), 'taxonomy_fields' => array(array('label' => 'ID', 'value' => 'term_id', 'default' => 1), array('label' => 'Name', 'value' => 'name', 'default' => 0), array('label' => 'Slug', 'value' => 'slug', 'default' => 0)), 'taxonomy_operators' => array(array('value' => 'IN', 'default' => 1, 'label' => 'Match Any'), array('value' => 'NOT IN', 'default' => 0, 'label' => 'Match None'), array('value' => 'AND', 'default' => 0, 'label' => 'Match All'), array('value' => 'EXISTS', 'default' => 0, 'label' => 'Exists'), array('value' => 'NOT EXISTS', 'default' => 0, 'label' => 'Not Exists'))); return $jsData; }
<?php $main = meAnjanWqg_Main::getInstance(); $idPrefix = $main->getConfig('idPrefix'); $wqgData = meAnjanWqg_Utils::getData(); if (empty($wqgData)) { $wqgData = array(); } $current_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $main = meAnjanWqg_Main::getInstance(); $tabs = array(array('id' => $idPrefix . 'tab-author', 'label' => 'Author', 'slug' => 'author', 'active' => TRUE), array('id' => $idPrefix . 'tab-category', 'label' => 'Category', 'slug' => 'category', 'active' => FALSE), array('id' => $idPrefix . 'tab-tag', 'label' => 'Tag', 'slug' => 'tag', 'active' => FALSE), array('id' => $idPrefix . 'tab-taxonomy', 'label' => 'Taxonomy', 'slug' => 'taxonomy', 'active' => FALSE), array('id' => $idPrefix . 'tab-search', 'label' => 'Search', 'slug' => 'search', 'active' => FALSE), array('id' => $idPrefix . 'tab-post', 'label' => 'Post', 'slug' => 'post', 'active' => FALSE), array('id' => $idPrefix . 'tab-date', 'label' => 'Date (Simple)', 'slug' => 'date', 'active' => FALSE), array('id' => $idPrefix . 'tab-date-query', 'label' => 'Date (Advanced)', 'slug' => 'date-query', 'active' => FALSE), array('id' => $idPrefix . 'tab-meta', 'label' => 'Meta/Custom Field', 'slug' => 'meta', 'active' => FALSE), array('id' => $idPrefix . 'tab-meta-query', 'label' => 'Meta Query', 'slug' => 'meta-query', 'active' => FALSE), array('id' => $idPrefix . 'tab-sorting', 'label' => 'Sorting', 'slug' => 'sorting', 'active' => FALSE), array('id' => $idPrefix . 'tab-pagination', 'label' => 'Pagination', 'slug' => 'pagination', 'active' => FALSE)); $currentTab = trim(meAnjanWqg_Utils::arrayValue($wqgData, 'currentTab')); if ($currentTab == '') { $currentTab = $idPrefix . 'tab-author'; } foreach ($tabs as &$t) { $t['active'] = $currentTab == $t['id']; } ?> <div class="wrap" id="<?php echo $idPrefix . $main->getConfig('html/ids/generator_container'); ?> "> <h2>WP_Query Parameters Generator</h2> <form action="" method="POST" class="form-horizontal" role="form" id="<?php echo $idPrefix . $main->getConfig('html/ids/generator_form'); ?> ">