/** * Builds a URL relative to the GlotPress' domain root. * * @param mixed $path string path or array of path components * @param array $query associative array of query arguments (optional) */ function gp_url($path = '/', $query = null) { $base = gp_url_path(gp_url_public_root()); $base = '/' . ltrim($base, '/'); // Make sure `$base` has always a leading slash. return apply_filters('gp_url', gp_url_add_path_and_query($base, $path, $query), $path, $query); }
public function gp_pre_tmpl_load($template, $args) { $url = gp_url_public_root(); if (is_ssl()) { $url = gp_url_ssl($url); } gp_enqueue_script('gp-remove-powered-by'); }
public function gp_pre_tmpl_load($template, $args) { $url = gp_url_public_root(); if (is_ssl()) { $url = gp_url_ssl($url); } gp_enqueue_script('new-window-for-external-links'); }
public function pre_tmpl_load($template, $args) { $url = gp_url_public_root(); if (is_ssl()) { $url = gp_url_ssl($url); } wp_enqueue_script('remove-powered-by', $url . 'plugins/remove-powered-by/remove-powered-by.js', array('jquery')); }
public function pre_tmpl_load($template, $args) { $url = gp_url_public_root(); if (is_ssl()) { $url = gp_url_ssl($url); } wp_enqueue_script('new-window-for-external-links', $url . 'plugins/new-window-for-external-links/new-window-for-external-links.js', array('jquery')); }
public function route() { global $wp_query; $real_request_uri = $this->request_uri(); $api_request_uri = $real_request_uri; $request_method = strtolower($this->request_method()); $api = gp_startswith($real_request_uri, '/' . $this->api_prefix . '/'); if ($api) { $real_request_uri = substr($real_request_uri, strlen($this->api_prefix) + 1); } $url_path = gp_url_path(gp_url_public_root()); // If the request URL doesn't match our base URL, don't bother trying to match if ($url_path && !gp_startswith($_SERVER['REQUEST_URI'], $url_path)) { return; } foreach (array($api_request_uri, $real_request_uri) as $request_uri) { foreach ($this->urls as $re => $func) { foreach (array('get', 'post', 'head', 'put', 'delete') as $http_method) { if (gp_startswith($re, $http_method . ':')) { if ($http_method != $request_method) { continue; } $re = substr($re, strlen($http_method . ':')); break; } } if (preg_match("@^{$re}\$@", $request_uri, $matches)) { /* * WordPress will be returning a 404 status header by default for GlotPress pages * as nothing is found by WP_Query. * This overrides the status header and the `$is_404` property of WP_Query if we've matched * something here. Route controllers still can return a 404 status header. */ status_header('200'); $wp_query->is_404 = false; if (is_array($func)) { list($class, $method) = $func; $route = new $class(); $route->api = $api; $route->last_method_called = $method; $route->class_name = $class; GP::$current_route =& $route; $route->before_request(); $route->request_running = true; // make sure after_request() is called even if we $this->exit_() in the request register_shutdown_function(array(&$route, 'after_request')); call_user_func_array(array($route, $method), array_slice($matches, 1)); $route->after_request(); $route->request_running = false; } else { call_user_func_array($func, array_slice($matches, 1)); } exit; } } } gp_tmpl_404(); }
public function __construct() { parent::__construct(); $this->add_action('plugins_loaded'); $this->add_filter('tmpl_load_locations', array('args' => 4)); $url = gp_url_public_root(); wp_enqueue_script('tec', $url . '/plugins/tec-theme/templates/js/tec.js', array('jquery')); if (is_object) { GP::$translation->per_page = 30; } }
public function admin_menu() { global $menu; $image = plugins_url('/GlotPress-Logo-20px.png', __FILE__); // Add the menu to the admin menu. add_menu_page(__('GlotPress'), __('GlotPress'), 'read', __FILE__, array($this, 'redirect_to_glotpress'), $image, 1); // We're going to hack the menu info to use a link to the front end instead of calling the 'redirect_to_glotpress' function so we save a page load. foreach ($menu as $tag => $mi) { if ($mi[0] == __('GlotPress')) { $menu[$tag][2] = gp_url_public_root(); } } }
public function pre_tmpl_load($template, $args) { if ('translations' != $template) { return; } if (!$args['locale']->google_code) { return; } $url = gp_url_public_root(); if (is_ssl()) { $url = gp_url_ssl($url); } $options = array('key' => $this->key, 'locale' => $args['locale']->google_code); wp_enqueue_script('google-translate', $url . '/plugins/google-translate/google-translate.js', array('jquery', 'editor')); wp_localize_script('google-translate', 'gp_google_translate', $options); }
/** * Builds a URL relative to the GlotPress' domain root. * * @param mixed $path string path or array of path components * @param array $query associative array of query arguments (optional) */ function gp_url($path = '/', $query = null) { $base = gp_url_path(gp_url_public_root()); $base = '/' . ltrim($base, '/'); // Make sure `$base` has always a leading slash. /** * Filter a URL relative to GlotPress' domain root. * * @since 1.0.0 * * @param string $base The base path. * @param string|array $path The GlotPress path or the components as an array. * @param string $query The query part of the URL. */ return apply_filters('gp_url', gp_url_add_path_and_query($base, $path, $query), $path, $query); }
function login_post() { global $wp_users_object, $wp_auth_object; $user = GP::$user->by_login($_POST['user_login']); if (!$user || is_wp_error($user)) { $this->errors[] = __("Invalid username!"); $this->redirect(gp_url_login()); return; } if ($user->login(gp_post('user_pass'))) { if (gp_post('redirect_to')) { $this->redirect(gp_post('redirect_to')); } else { $this->notices[] = sprintf(__("Welcome, %s!"), $_POST['user_login']); $this->redirect(gp_url_public_root()); } } else { $this->errors[] = __("Invalid password!"); $this->redirect(gp_url_login()); } }
<?php wp_enqueue_style('base'); wp_enqueue_style('open-sans', 'https://fonts.googleapis.com/css?family=Open+Sans:600,400', false, 'all'); $url = gp_url_public_root(); wp_enqueue_style('font', $url . '/plugins/tec-theme/templates/css/font.css'); wp_enqueue_style('main', $url . '/plugins/tec-theme/templates/css/main.css'); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> <title><?php echo gp_title(); ?> </title> <?php gp_head(); ?> </head> <body <?php body_class(); ?> > <header> <div class="logo" itemscope="" itemprop="author headline" itemtype="https://schema.org/Organization"> <h1 class="logo-wrap"> <a href="http://translations.theeventscalendar.com" class="logo-anchor" rel="home" itemprop="url">
/** * @ticket gh-203 */ function test_gp_url_public_root_has_a_trailing_slash_when_permalinks_have_a_trailing_slash() { $this->set_permalink_structure(GP_TESTS_PERMALINK_STRUCTURE_WITH_TRAILING_SLASH); $this->assertTrue('/' === substr(gp_url_public_root(), -1)); }
?> <h2><?php _e('Create New Project', 'glotpress'); ?> </h2> <form action="" method="post"> <?php gp_tmpl_load('project-form', get_defined_vars()); ?> <p> <input type="submit" name="submit" value="<?php esc_attr_e('Create', 'glotpress'); ?> " id="submit" /> <span class="or-cancel"><?php _e('or', 'glotpress'); ?> <a href="<?php echo esc_url(gp_url_public_root()); ?> "><?php _e('Cancel', 'glotpress'); ?> </a></span> </p> <?php gp_route_nonce_field('add-project'); ?> </form> <?php gp_tmpl_footer();
/** * Builds a URL relative to the GlotPress' domain root * * @param mixed $path string path or array of path components * @param array $query associative array of query arguments (optional) */ function gp_url($path = '/', $query = null) { return apply_filters('gp_url', gp_url_add_path_and_query(gp_url_path(gp_url_public_root()), $path, $query), $path, $query); }
<?php wp_enqueue_style('wporg', (is_ssl() ? gp_url_ssl(gp_url_public_root()) : gp_url_public_root()) . 'gp-templates/style.css', array('base'), '20130531'); add_action('tmpl_load_locations', function ($locations, $template, $args, $template_path) { $core_templates = GP_PATH . 'gp-templates/'; require_once $core_templates . 'helper-functions.php'; $locations[] = $core_templates; return $locations; }, 50, 4); add_filter('gp_breadcrumb', function ($breadcrumb) { $breadcrumb = preg_replace('#<span class="separator">(.*?)</span>#', '', $breadcrumb, 1); if (false !== strpos($breadcrumb, '<span class="active bubble">')) { $breadcrumb = str_replace('</span><span class="active bubble">', ' <span class="active bubble">', $breadcrumb) . '</span>'; } return $breadcrumb; }, 11); // After bubble is added by lamba() in gp-templates/project.php
/** * @ticket gh-203 */ function test_gp_url_public_root_has_a_trailing_slash_when_permalinks_have_a_trailing_slash() { $this->set_permalink_structure('/%postname%/'); $this->assertTrue('/' === substr(gp_url_public_root(), -1)); }
/** * Deletes a project, including sub projects, glossaries, originals, translations sets and translations. * * @since 2.0.0 * * @param int $project_path The path of the project to delete. */ public function delete_post($project_path) { $project = GP::$project->by_path($project_path); if (!is_object($project)) { $this->redirect(gp_url_public_root()); $this->errors[] = __('Error in deleting project!', 'glotpress'); return; } if ($this->invalid_nonce_and_redirect('delete-project_' . $project->id)) { return; } if ($this->cannot_and_redirect('delete', 'project', $project->id)) { return; } if ($project->delete()) { $this->notices[] = sprintf(__('The project "%s" was deleted.', 'glotpress'), $project->name); } else { $this->errors[] = sprintf(__('Error deleting project "%s"!', 'glotpress'), $project->name); } $this->redirect(gp_url_public_root()); }
public function pre_tmpl_load($template, $args) { if (GP::$user->logged_in()) { $user_obj = GP::$user->current(); $user = strtoupper($user_obj->user_login); $user_key = gp_const_get('GP_GOOGLE_TRANSLATE_KEY_' . $user); if ($user_key) { $this->key = $user_key; } } if (!$this->key) { return; } if ('translations' != $template) { return; } if (!$args['locale']->google_code) { return; } $url = gp_url_public_root(); if (is_ssl()) { $url = gp_url_ssl($url); } $options = array('key' => $this->key, 'locale' => $args['locale']->google_code); wp_enqueue_script('google-translate', $url . '/plugins/google-translate/google-translate.js', array('jquery', 'editor')); wp_localize_script('google-translate', 'gp_google_translate', $options); }