Skip to content

Commit

Permalink
Issue #12 Rename some genesis_oik_ prefixed functions to genesis_a2z_…
Browse files Browse the repository at this point in the history
…. More to be done
  • Loading branch information
bobbingwide committed Mar 8, 2017
1 parent b1cfa67 commit ea24172
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 5 deletions.
13 changes: 8 additions & 5 deletions functions.php
Expand Up @@ -21,7 +21,7 @@
* @param string $text Standard Genesis footer credits to override
* @return string What we actually want
*/
function oik_footer_creds_text( $text ) {
function genesis_a2z_footer_creds_text( $text ) {
do_action( "oik_add_shortcodes" );
$text = "[bw_wpadmin]";
$text .= '<br />';
Expand Down Expand Up @@ -76,12 +76,15 @@ function genesis_a2z_register_sidebars() {
* @TODO Do we need this for genesis-a2z?
*/
function genesis_a2z_edd() {
add_filter( "edd_checkout_image_size", "goik_edd_checkout_image_size", 10, 2 );
add_filter( "edd_checkout_image_size", "ga2z_edd_checkout_image_size", 10, 2 );
//remove_action( "edd_user_register", 'edd_process_register_form' );
add_action( "edd_process_register_form", "genesis_a2z_edd_process_register_form" );
}

function goik_edd_checkout_image_size( $dimensions ) {
/**
* Implements 'edd_checkout_image_size'
*/
function ga2z_edd_checkout_image_size( $dimensions ) {
return( array( "auto", "auto" ) );
}

Expand Down Expand Up @@ -136,7 +139,7 @@ function genesis_oik_post_info() {
* attachment | sidebar-alt
*
*/
function genesis_oik_get_sidebar() {
function genesis_a2z_get_sidebar() {
//* Output primary sidebar structure
genesis_markup( array(
'html5' => '<aside %s>',
Expand Down Expand Up @@ -217,7 +220,7 @@ function genesis_a2z_functions_loaded() {

add_theme_support( 'genesis-footer-widgets', 2 );

add_filter( 'genesis_footer_creds_text', "oik_footer_creds_text" );
add_filter( 'genesis_footer_creds_text', "genesis_a2z_footer_creds_text" );

add_filter( 'genesis_pre_get_option_site_layout', 'genesis_a2z_pre_get_option_site_layout', 10, 2 );

Expand Down
15 changes: 15 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,15 @@
<phpunit
bootstrap="../../plugins/oik-batch/oik-wp.php"
backupGlobals="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<!-- for PHPUnit 4.8.0 or 5.5.2 -->
<testsuites>
<testsuite>
<directory prefix="test-" suffix=".php">tests/</directory>
</testsuite>
</testsuites>
</phpunit>
Binary file removed screenshot.jpg
Binary file not shown.
77 changes: 77 additions & 0 deletions tests/test-issue-12-rename-genesis-oik.php
@@ -0,0 +1,77 @@
<?php // (C) Copyright Bobbing Wide 2017

/**
* Can we confirm that all the genesis_oik logic has been renamed in the theme?
*
* i.e can we confirm that all the functions have a genesis_a2z_ or ga2z_ prefix?
*/
class Tests_issue_12_rename_genesis_oik extends BW_UnitTestCase {

public $functionsphp;

/**
*
* Finds the name of the functions.php file
* `C:\apache\htdocs\wordpress\wp-content\themes\genesis-oik/functions.php`
* with \ converted to /
*/
function setUp() {
parent::setUp();
$this->functionsphp = dirname( __DIR__ ) . "/functions.php";
$this->functionsphp = str_replace( "\\", '/', $this->functionsphp );
}

/**
* Checks if function implemented in functions.php
*
* Note: We don't allowe methods in functions.php
*
* @param $infile
* @return bool true if this is the theme's functions.php file
*/
function isfunctionsphp( $infile ) {
$infile = str_replace( "\\", '/', $infile );
//echo $infile . PHP_EOL;
$isfunctionsphp = false;
$isfunctionsphp = $infile == $this->functionsphp;
return( $isfunctionsphp );
}

/**
* Tests all functions in functions.php are prefixed correctly
*
*/
function test_all_my_user_functions_prefixed_genesis_oik() {
$functions = get_defined_functions();
foreach ( $functions['user'] as $func ) {
$f = new ReflectionFunction( $func );
$infile = $f->getFileName();
if ( $this->isfunctionsphp( $infile ) ) {
$allowed = $this->checkfuncprefix( $func );
$this->assertTrue( $allowed, "func doesn't have allowed prefix for this theme: " . $func );
}
}
}

/**
* Checks for allowed prefixes
*
* Note: We'll allow _e_c() until it's been removed from the template files.
*
* @param string $func
* @return bool true if it's an allowed prefix
*/
function checkfuncprefix( $func ) {
$allowed_prefixes = array( "genesis_a2z_", "ga2z_", "genesis_oik_", "_e_c" );
$allowed = false;
foreach ( $allowed_prefixes as $prefix ) {
if ( !$allowed ) {
$allowed = ( 0 === strpos( $func, $prefix ) );
}
}
return $allowed;
}



}

0 comments on commit ea24172

Please sign in to comment.