Example #1
0
File: p2.php Project: alx/pressmark
 function init()
 {
     load_theme_textdomain('p2', get_template_directory() . '/languages');
     add_filter('the_content', 'make_clickable');
     if (isset($_REQUEST['p2ajax'])) {
         require_once P2_INC_PATH . '/ajax.php';
         P2Ajax::dispatch();
         die;
     }
     if (function_exists('is_site_admin') && !is_site_admin()) {
         return;
     }
     $is_media_upload = isset($_REQUEST['p2-upload']);
     // don't redirect to https version when uploading files, since the domain may be different
     // and we don't have SSL certificates for blog domain, only for admin
     if ($is_media_upload && isset($GLOBALS['pagenow']) && 'media-upload.php' == $GLOBALS['pagenow']) {
         force_ssl_admin(is_ssl());
         add_filter('get_user_option_use_ssl', returner(false));
     }
     if ($is_media_upload) {
         add_filter('flash_uploader', returner(false));
         add_filter('auth_redirect_scheme', returner('logged_in'));
         add_filter('admin_url', array('P2', 'url_filter'));
         add_filter('includes_url', array('P2', 'url_filter'));
         add_filter('script_loader_src', array('P2', 'url_filter'));
         add_filter('wp_get_attachment_url', lambda('$url', 'str_replace(get_bloginfo("url")."/", site_url("/"), $url);'), 11);
         add_filter('media_upload_form_url', lambda('$url', 'add_query_arg( array( "p2-upload" => "true" ), $url );'));
     }
 }
Example #2
0
 function setUp()
 {
     global $gpdb;
     $gpdb->suppress_errors = false;
     $gpdb->show_errors = false;
     if (defined('GP_DEBUG') && GP_DEBUG) {
         if (defined('E_DEPRECATED')) {
             error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
         } else {
             error_reporting(E_ALL);
         }
     }
     ini_set('display_errors', 1);
     if (!gp_const_get('GP_IS_TEST_DB_INSTALLED')) {
         $gpdb->query('DROP DATABASE ' . GPDB_NAME . ";");
         $gpdb->query('CREATE DATABASE ' . GPDB_NAME . ";");
         $gpdb->select(GPDB_NAME, $gpdb->dbh);
         $gpdb->query('SET storage_engine = INNODB;');
         $errors = gp_install();
         if ($errors) {
             gp_error_log_dump($errors);
             die('ERROR: gp_install() returned errors! Check the error_log for complete SQL error message');
         }
         define('GP_IS_TEST_DB_INSTALLED', true);
     }
     $this->factory = new GP_UnitTest_Factory();
     $this->clean_up_global_scope();
     $this->start_transaction();
     ini_set('display_errors', 1);
     $this->url_filter = returner($this->url);
     add_filter('gp_get_option_uri', $this->url_filter);
 }
 function test_gp_array_any()
 {
     $this->assertEquals(false, gp_array_any('intval', array(0)));
     $this->assertEquals(false, gp_array_any(returner(false), array(1, 2, 3, 4)));
     $this->assertEquals(false, gp_array_any(returner(true), array()));
     $this->assertEquals(true, gp_array_any(returner(true), array(1, 2, 3, 4)));
     $this->assertEquals(true, gp_array_any(returner('$x', '$x % 2'), array(1, 2, 3, 4)));
 }
Example #4
0
 function setUp()
 {
     parent::setUp();
     $this->factory = new GP_UnitTest_Factory();
     $this->url_filter = returner($this->url);
     global $wp_rewrite;
     if ($wp_rewrite->permalink_structure) {
         $this->set_permalink_structure('');
     }
 }
Example #5
0
 function setUp()
 {
     parent::setUp();
     $this->factory = new GP_UnitTest_Factory();
     $this->url_filter = returner($this->url);
     global $wp_rewrite;
     if (GP_TESTS_PERMALINK_STRUCTURE != $wp_rewrite->permalink_structure) {
         $this->set_permalink_structure(GP_TESTS_PERMALINK_STRUCTURE);
     }
 }
Example #6
0
    return $depth;
}
function prologue_get_comment_depth($comment_id)
{
    return prologue_comment_depth_loop($comment_id, 1);
}
function prologue_comment_depth($comment_id)
{
    echo prologue_get_comment_depth($comment_id);
}
function prologue_poweredby_link()
{
    return apply_filters('prologue_poweredby_link', sprintf(__('<strong>%1$s</strong> is proudly powered by %2$s.', 'p2'), get_bloginfo('name'), '<a href="http://wordpress.org/" rel="generator">WordPress</a>'));
}
if (defined('IS_WPCOM') && IS_WPCOM) {
    add_filter('prologue_poweredby_link', returner('<a href="http://wordpress.com/" rel="generator">Get a free blog at WordPress.com</a>'));
}
/* Custom Header Code */
define('HEADER_TEXTCOLOR', '3478E3');
define('HEADER_IMAGE', '');
// %s is theme dir uri
define('HEADER_IMAGE_WIDTH', 980);
define('HEADER_IMAGE_HEIGHT', 120);
function p2_admin_header_style()
{
    ?>
	<style type="text/css">
	#headimg {
		background: url(<?php 
    header_image();
    ?>
Example #7
0
 function discard_warning($project_path, $locale_slug, $translation_set_slug)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$project || !$locale || !$translation_set) {
         gp_tmpl_404();
     }
     $this->can_or_forbidden('write', 'project', $project->id);
     $translation = GP::$translation->get(gp_post('translation_id'));
     if (!$translation) {
         $this->die_with_error('Translation doesn&#8217;t exist!');
     }
     if (!isset($translation->warnings[gp_post('index')][gp_post('key')])) {
         $this->die_with_error('The warning doesn&#8217;exist!');
     }
     unset($translation->warnings[gp_post('index')][gp_post('key')]);
     if (empty($translation->warnings[gp_post('index')])) {
         unset($translation->warnings[gp_post('index')]);
     }
     $res = $translation->save();
     if (!$res) {
         $this->die_with_error('Error in saving the translation!');
     }
     $translations = GP::$translation->for_translation($project, $translation_set, 'no-limit', array('translation_id' => gp_post('translation_id')), array());
     if ($translations) {
         $t = $translations[0];
         $parity = returner('even');
         $can_edit = GP::$user->logged_in();
         $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
         gp_tmpl_load('translation-row', get_defined_vars());
     } else {
         $this->die_with_error('Error in retrieving translation!');
     }
 }
    return $depth;
}
function prologue_get_comment_depth($comment_id)
{
    return prologue_comment_depth_loop($comment_id, 1);
}
function prologue_comment_depth($comment_id)
{
    echo prologue_get_comment_depth($comment_id);
}
function prologue_poweredby_link()
{
    return apply_filters('prologue_poweredby_link', sprintf(__('<strong>%1$s</strong> is proudly powered by %2$s.', 'p2'), get_bloginfo('name'), '<a href="http://wordpress.org/" rel="generator">WordPress</a>'));
}
if (defined('IS_WPCOM') && IS_WPCOM) {
    add_filter('prologue_poweredby_link', returner('<a href="http://wordpress.com/">' . __('Blog at WordPress.com', 'p2') . '.</a>'));
}
/* Custom Header Code */
define('HEADER_TEXTCOLOR', '3478E3');
define('HEADER_IMAGE', '');
// %s is theme dir uri
define('HEADER_IMAGE_WIDTH', 980);
define('HEADER_IMAGE_HEIGHT', 120);
function p2_admin_header_style()
{
    ?>
	<style type="text/css">
	#headimg{
		background: url(<?php 
    header_image();
    ?>
Example #9
0
 private function edit_single_translation($project_path, $locale_slug, $translation_set_slug, $edit_function)
 {
     $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();
     }
     $translation = GP::$translation->get(gp_post('translation_id'));
     if (!$translation) {
         return $this->die_with_error('Translation doesn&#8217;t exist!');
     }
     $this->can_approve_translation_or_forbidden($translation);
     call_user_func($edit_function, $project, $locale, $translation_set, $translation);
     $translations = GP::$translation->for_translation($project, $translation_set, 'no-limit', array('translation_id' => $translation->id, 'status' => 'either'), array());
     if ($translations) {
         $t = $translations[0];
         $parity = returner('even');
         $can_edit = GP::$user->logged_in();
         $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
         $this->tmpl('translation-row', get_defined_vars());
     } else {
         return $this->die_with_error('Error in retrieving translation!');
     }
 }