function new_post() { $new_glossary = new GP_Glossary(gp_post('glossary')); $translation_set = $new_glossary->translation_set_id ? GP::$translation_set->get($new_glossary->translation_set_id) : null; if (!$translation_set) { $this->redirect_with_error(__('Cannot find translation set with this ID.'), gp_url('/glossaries/-new', array('translation_set_id' => $new_glossary->translation_set_id))); return; } if (GP::$glossary->by_set_id($new_glossary->translation_set_id)) { $this->redirect_with_error(__('The glossary for this translation set already exists.'), gp_url('/glossaries/-new', array('translation_set_id' => $new_glossary->translation_set_id))); return; } if ($this->cannot_edit_glossary_and_redirect($new_glossary)) { return; } $created_glossary = GP::$glossary->create_and_select($new_glossary); if ($created_glossary) { $this->notices[] = __('The glossary was created!'); $set_project = GP::$project->get($translation_set->project_id); $this->redirect(gp_url_join(gp_url_project($set_project, array($translation_set->locale, $translation_set->slug)), array('glossary'))); } else { $this->errors[] = __('Error in creating glossary!'); $this->redirect(gp_url('/glossaries/-new', array('translation_set_id' => $new_glossary->translation_set_id))); } }
function after_notices() { if ($this->is_notice_hidden()) { return; } $hide_url = gp_url('/getting-started/hide-notice'); ?> <div class="notice" id="help-notice"> New to <em>translate.wordpress.org</em>? Have a look at the <a href="<?php echo esc_url(gp_url('/getting-started')); ?> ">Getting Started guide.</a> <a id="hide-help-notice" class="secondary" style="float: right;" href="<?php echo esc_url($hide_url); ?> ">Hide</a> </div> <script type="text/javascript"> jQuery('#hide-help-notice').click(function() { jQuery.ajax({url: '<?php echo esc_js($hide_url); ?> '}); jQuery('#help-notice').fadeOut(1000); return false; }); </script> <?php }
public function gp_project_actions($actions, $project) { $project_settings = (array) get_option('gp_auto_extract', array()); if ('none' != $project_settings[$project->id]['type']) { $actions[] .= gp_link_get(gp_url('auto-extract/' . $project->slug), __('Auto Extract')); } return $actions; }
function profile_post() { if (isset($_POST['submit'])) { $per_page = (int) $_POST['per_page']; GP::$user->current()->set_meta('per_page', $per_page); $default_sort = $_POST['default_sort']; GP::$user->current()->set_meta('default_sort', $default_sort); } $this->redirect(gp_url('/profile')); }
function profile_post() { if (isset($_POST['submit'])) { $per_page = (int) $_POST['per_page']; update_user_option(get_current_user_id(), 'gp_per_page', $per_page); $default_sort = array('by' => 'priority', 'how' => 'desc'); $user_sort = wp_parse_args($_POST['default_sort'], $default_sort); update_user_option(get_current_user_id(), 'gp_default_sort', $user_sort); } $this->redirect(gp_url('/profile')); }
function profile_post() { if (isset($_POST['submit'])) { $per_page = (int) $_POST['per_page']; GP::$user->current()->set_meta('per_page', $per_page); $default_sort = array('by' => 'priority', 'how' => 'desc'); $user_sort = wp_parse_args($_POST['default_sort'], $default_sort); GP::$user->current()->set_meta('default_sort', $user_sort); } $this->redirect(gp_url('/profile')); }
function gp_scripts_default(&$scripts) { $scripts->base_url = gp_url('js'); $scripts->default_version = gp_get_option('version'); $scripts->add('jquery', '/jquery/jquery.js', array(), '1.3.2-min'); $scripts->add('jquery-ui-core', '/jquery/ui.core.js', array('jquery'), '1.7.2'); $scripts->add('jquery-ui-tabs', '/jquery/ui.tabs.js', array('jquery-ui-core'), '1.7.2'); $scripts->add('jquery-ui-tabs', '/jquery/ui.tabs.js', array('jquery-ui-core'), '1.7.2'); $scripts->add('jquery-ui-selectable', '/jquery/ui.selectable.js', array('jquery-ui-core'), '1.7.2'); $scripts->add('common', '/common.js', array('jquery')); $scripts->add('editor', '/editor.js', array('common')); $scripts->add('translations-page', '/translations-page.js', array('common')); }
function test_gp_url() { $this->assertEquals($this->url . 'baba', gp_url('baba')); $this->assertEquals($this->url . 'baba', gp_url('baba', '')); $this->assertEquals($this->url . 'baba', gp_url('baba', array())); $this->assertEquals($this->url . '?a=b', gp_url('', 'a=b')); $this->assertEquals($this->url . '?a=b', gp_url('', '?a=b')); $this->assertEquals($this->url . '?a=b', gp_url('', array('a' => 'b'))); $this->assertEquals($this->url . '?a=b&b=c', gp_url('', array('a' => 'b', 'b' => 'c'))); $this->assertEquals($this->url . 'baba?a=b&b=c', gp_url('baba', array('a' => 'b', 'b' => 'c'))); $this->assertEquals($this->url . 'baba/wink?a=b&b=c', gp_url('/baba/wink', array('a' => 'b', 'b' => 'c'))); $this->assertEquals($this->url . 'baba/wink?a=a%26b&b=c', gp_url('/baba/wink', array('a' => 'a&b', 'b' => 'c'))); }
function new_post() { $new_set = new GP_Translation_Set(gp_post('set')); if ($new_set->project_id) { $this->can_or_redirect('write', 'project', $new_set->project_id, gp_url_project(GP::$project->get($new_set->project_id))); } else { $this->can_or_redirect('write', 'project', null, gp_url_project('')); } $this->validate_or_redirect($new_set, gp_url('/sets/_new', array('project_id' => $new_set->project_id))); $set = GP::$translation_set->create_and_select($new_set); $project = GP::$project->get($set->project_id); if (!$set) { $this->errors[] = __('Error in creating translation set!'); gp_redirect(gp_url('/sets/_new', array('project_id' => $new_set['project_id']))); } else { $this->notices[] = __('The translation set was created!'); gp_redirect(gp_url_project_locale($project, $set->locale, $set->slug)); } }
public static function get($option) { switch ($option) { case 'application_id': return 'glotpress'; case 'application_uri': return gp_url(); case 'cron_uri': return ''; case 'cron_check': return ''; case 'charset': return 'UTF-8'; case 'wp_http_version': return 'GlotPress/' . gp_get_option('version'); case 'hash_function_name': return 'gp_hash'; default: return gp_get_option(BP_Options::prefix() . $option); } }
/** * Saves settings for a user and redirects back to the settings page. * * @param int $user_id Optional. A user id, if not provided the id of the currently logged in user will be used. */ public function settings_post($user_id = null) { if (isset($_POST['submit'])) { // Sometimes we get null, sometimes we get 0, depending on where it comes from. // Let's make sure we have a consistent value to test against and that it's an integer. $user_id = (int) $user_id; if (0 === $user_id) { $user_id = get_current_user_id(); } if ($this->invalid_nonce_and_redirect('update-settings_' . $user_id)) { return; } $per_page = (int) $_POST['per_page']; update_user_option($user_id, 'gp_per_page', $per_page); $default_sort = array('by' => 'priority', 'how' => 'desc'); $user_sort = wp_parse_args($_POST['default_sort'], $default_sort); update_user_option($user_id, 'gp_default_sort', $user_sort); $this->notices[] = __('Settings saved!', 'glotpress'); } $this->redirect(gp_url('/settings')); exit; }
function edit_post($set_id) { $items = $this->get_set_project_and_locale_from_set_id_or_404($set_id); if (!$items) { return; } list($set, $project, $locale) = $items; $new_set = new GP_Translation_Set(gp_post('set', array())); if ($this->cannot_edit_set_and_redirect($new_set)) { return; } if ($this->invalid_and_redirect($new_set, gp_url('/sets/-new'))) { return; } if (!$set->update($new_set)) { $this->errors[] = __('Error in updating translation set!'); $this->redirect(); return; } $project = GP::$project->get($new_set->project_id); $this->notices[] = __('The translation set was updated!'); $this->redirect(gp_url_project_locale($project, $new_set->locale, $new_set->slug)); }
echo esc_html($translation_set->name); ?> <?php gp_link_set_edit($translation_set, $project, __('(edit)', 'glotpress')); ?> <?php if ($glossary) { ?> <?php echo gp_link($glossary->path(), __('glossary', 'glotpress'), array('class' => 'glossary-link')); ?> <?php } elseif ($can_approve) { ?> <?php echo gp_link_get(gp_url('/glossaries/-new', array('translation_set_id' => $translation_set->id)), __('Create glossary', 'glotpress'), array('class' => 'glossary-link')); ?> <?php } ?> </h2> <?php if ($can_approve) { ?> <form id="bulk-actions-toolbar" class="filters-toolbar bulk-actions" action="<?php echo $bulk_action; ?> " method="post"> <div> <select name="bulk[action]" id="bulk-action"> <option value="" selected="selected"><?php
<?php printf(__("Translation of %s"), esc_html($project->name)); ?> : <span><?php echo esc_html($translation_set->name); ?> </span> <?php gp_link_set_edit($translation_set, $project, __('Edit'), array('class' => 'btn btn-xs btn-primary')); ?> <?php if ($glossary) { echo gp_link(gp_url_project_locale($project, $locale->slug, $translation_set->slug) . '/glossary', __('glossary'), array('class' => 'btn btn-xs btn-primary')); } elseif ($can_approve) { echo gp_link_get(gp_url('/glossaries/-new', array('translation_set_id' => $translation_set->id)), __('Create glossary'), array('class' => 'btn btn-xs btn-primary')); } ?> </h2> <?php if ($can_approve) { ?> <form id="bulk-actions-toolbar" class="filters-toolbar bulk-actions form-inline pull-left" action="<?php echo $bulk_action; ?> " method="post" role="form"> <select name="bulk[action]" id="bulk-action" class="form-control input-sm"> <option value="" selected="selected"><?php _e('Bulk Actions'); ?>
function translations_get($project_path, $locale_slug, $translation_set_slug) { $project = GP::$project->by_path($project_path); $locale = GP_Locales::by_slug($locale_slug); if (!$project || !$locale) { return $this->die_with_404(); } $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug); if (!$translation_set) { return $this->die_with_404(); } $glossary = GP::$glossary->by_set_or_parent_project($translation_set, $project); $page = gp_get('page', 1); $filters = gp_get('filters', array()); $sort = gp_get('sort', array()); if ('random' == gp_array_get($sort, 'by')) { add_filter('gp_pagination', '__return_null'); } $per_page = get_user_option('gp_per_page'); if (0 == $per_page) { $per_page = GP::$translation->per_page; } else { GP::$translation->per_page = $per_page; } $translations = GP::$translation->for_translation($project, $translation_set, $page, $filters, $sort); $total_translations_count = GP::$translation->found_rows; $can_edit = $this->can('edit', 'translation-set', $translation_set->id); $can_write = $this->can('write', 'project', $project->id); $can_approve = $this->can('approve', 'translation-set', $translation_set->id); $url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug)); $set_priority_url = gp_url('/originals/%original-id%/set_priority'); $discard_warning_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-discard-warning')); $set_status_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-set-status')); $bulk_action = gp_url_join($url, '-bulk'); // Add action to use different font for translations add_action('gp_head', function () use($locale) { return gp_preferred_sans_serif_style_tag($locale); }); $this->tmpl('translations', get_defined_vars()); }
function gp_url_profile($user_nicename) { return apply_filters('gp_url_profile', gp_url(array('/profile', $user_nicename)), $user_nicename); }
<li class="list-group-item"> <?php gp_link_project($project, esc_html($project->name)); ?> <?php gp_link_project_edit($project, null, array('class' => 'btn btn-xs btn-primary')); ?> </li> <?php } ?> </ul> <p> <?php gp_link(gp_url('/languages'), __('Projects by language'), array('class' => 'btn btn-primary')); ?> <?php if (GP::$user->current()->can('write', 'project')) { ?> <?php gp_link(gp_url_project('-new'), __('Create a New Project'), array('class' => 'btn btn-default')); ?> <?php } ?> </p>
function gp_project_actions($project, $translation_sets) { $actions = array(gp_link_get(gp_url_project($project, 'import-originals'), __('Import originals')), gp_link_get(gp_url_project($project, array('-permissions')), __('Permissions')), gp_link_get(gp_url_project('', '-new', array('parent_project_id' => $project->id)), __('New Sub-Project')), gp_link_get(gp_url('/sets/-new', array('project_id' => $project->id)), __('New Translation Set')), gp_link_get(gp_url_project($project, array('-mass-create-sets')), __('Mass-create Translation Sets')), gp_link_get(gp_url_project($project, '-branch'), __('Branch Project')), gp_link_with_ays_get(gp_url_project($project, '-delete'), __('Delete Project'), array('ays-text' => 'Do you really want to delete this project?'))); $actions = apply_filters('gp_project_actions', $actions, $project); echo '<ul>'; foreach ($actions as $action) { echo '<li>' . $action . '</li>'; } if ($translation_sets) { echo '<li>' . gp_project_options_form($project) . '</li>'; } echo '</ul>'; }
function gp_link_glossary_edit_get($glossary, $set, $text = false, $attrs = array()) { if (!GP::$user->current()->can('approve', 'translation_set', $set->id)) { return ''; } $text = $text ? $text : __('Edit'); return gp_link_get(gp_url(gp_url_join('/glossaries', $glossary->id, '-edit')), $text, gp_attrs_add_class($attrs, 'action edit')); }
$url = __WP_HOME__ . '/api/user/register/?username='******'username']) . '&email=' . urlencode($date['email']) . '&nonce=' . urlencode($j->nonce) . '&display_name=' . urlencode($date['name'] . ' ' . $date['surname']) . '&first_name=' . urlencode($date['name']) . '&last_name=' . urlencode($date['surname']) . '&user_pass='******'password']); $user_info = json_decode(file_get_contents($url)); header('Location: ' . gp_url('/')); } gp_title(__('Projects < GlotPress')); gp_tmpl_header(); ?> <h2><?php _e('Register User'); ?> </h2> <div id="projects_box"> <img src="http://www.ctlr.it/translate/plugins/templates/img/ctlr.png" title="CTLR Translate" alt="CTLR Translate"/> <p>This is the home of the CTLR Translate. Here we translate all CTLR Software.</p> <p> If you're new, you can <a href="<?php echo gp_url('/register'); ?> ">register here</a> and start translating. We usually encourage people to start translating on one of our free plugins, if you're doing well we'll happily provide you a copy of one of the premium plugins to translate it.</p> </div> <div class="register_form"> <form action="" method="post"> <table class="form-table"> <tr> <td> <label ><?php echo _('Name'); ?> </label><br /> <input type="text" name="name" /> </td> <td>
function redirect($url = null) { if ($this->fake_request) { $this->redirected = true; $this->redirected_to = $url; return; } $this->set_notices_and_errors(); // TODO: do not redirect to projects, but to / // currently it goes to /projects, because / redirects too and the notice is gone if (is_null($url)) { $url = isset($_SERVER['HTTP_REFERER']) ? wp_unslash($_SERVER['HTTP_REFERER']) : gp_url('/projects'); } wp_redirect($url); $this->tmpl('redirect', compact('url')); }
public function gp_project_actions($actions, $project) { $actions[] .= gp_link_get(gp_url('bulk-export/' . $project->slug), __('Bulk Export Translations')); return $actions; }
?> <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 gp_url(); ?> "><?php _e('Cancel', 'glotpress'); ?> </a></span> </p> <?php gp_route_nonce_field('add-project'); ?> </form> <?php gp_tmpl_footer();
<li><?php gp_link_project($project, esc_html($project->name)); ?> <?php gp_link_project_edit($project, null, array('class' => 'bubble')); ?> </li> <?php } ?> </ul> <p class="actionlist secondary"> <?php if (current_user_can('manage_options')) { ?> <?php gp_link(gp_url_project('-new'), __('Create a New Project', 'glotpress')); ?> • <?php } ?> <?php gp_link(gp_url('/languages'), __('Projects by language', 'glotpress')); ?> </p> <?php gp_tmpl_footer();
function logout() { GP::$user->logout(); $this->redirect(gp_url('/')); }
?> /languages" data-toggle="tab" data-original-title="" title="">Languages</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <?php if (GP::$user->logged_in()) { $user = GP::$user->current(); echo '<li><a href="' . gp_url('/profile') . '">'; printf(__('Hi, %s.'), $user->user_login); echo '</a></li>'; ?> <li><a href="<?php echo gp_url('/logout'); ?> "><?php _e('Log out'); ?> </a></li> <?php } else { ?> <li><a href="<?php echo gp_url_login(); ?> "><?php _e('Log in'); ?>
<?php gp_title(__('Not Found < GlotPress')); gp_tmpl_header(); ?> <h2><?php _e('Page not found'); ?> </h2> <p>The page you requested could not be found.</p> <a href="<?php echo gp_url('/'); ?> " class="btn btn-large btn-primary"><span class="glyphicon glyphicon-home"></span> Take Me Home</a> <?php gp_tmpl_footer();
?> " rel="home"> <img alt="GlotPress" src="<?php echo apply_filters('gp_logo_img_url', gp_url_img('glotpress-logo.png')); ?> " /> </a> <?php echo gp_breadcrumb(); ?> <span id="hello"> <?php if (GP::$user->logged_in()) { $user = GP::$user->current(); printf(__('Hi, %s.'), '<a href="' . gp_url('/profile') . '">' . $user->user_login . '</a>'); $logout_string = '<a href="' . gp_url('/logout') . '">' . __('Log out') . '</a>'; echo apply_filters('gp_logout_link', $logout_string); ?> <?php } elseif (!GP_INSTALLING) { $login_string = '<strong><a href="' . gp_url_login() . '">' . __('Log in') . '</a></strong>'; echo apply_filters('gp_login_link', $login_string); } ?> <?php do_action('after_hello'); ?> </span> <div class="clearfix"></div> </h1> <div class="clear after-h1"></div>
/** * @ticket gh-203 */ function test_gp_url_returns_leading_slash_when_permalinks_have_no_trailing_slash() { add_filter('gp_url_base_path', array($this, '_gp_url_base_path_filter_empty_string')); $this->set_permalink_structure(GP_TESTS_PERMALINK_STRUCTURE); $this->assertSame('/foo/bar', gp_url('foo/bar')); remove_filter('gp_url_base_path', array($this, '_gp_url_base_path_filter_empty_string')); }
} } function ctlr_get_user_website($user_id) { global $gpdb; $out = $gpdb->get_var($gpdb->prepare("SELECT user_url FROM wp_users WHERE ID = %d", $user_id)); $out = trim($out); if ($out && $out !== '') { return $out; } else { return false; } } if (ctlr_get_user_meta('hide_profile', $user->id)) { if (!GP::$user->admin()) { header("Location: " . gp_url('/'), true, 307); exit; } } gp_title(__('Profile < GlotPress')); gp_breadcrumb(array(__('Profile'))); gp_tmpl_header(); ?> <h2><?php echo $user->display_name; ?> </h2> <div class="column"> <div class="user-card"> <img class="user-avatar alignright" src="<?php echo $user->get_avatar(240);