Completed
Branch dev (a3767f)
by Michael
40:38
created

getReadMeContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 8
rs 9.4286
ccs 0
cts 7
cp 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Admin Page Framework Loader
4
 * 
5
 * Demonstrates the usage of Admin Page Framework.
6
 * 
7
 * http://en.michaeluno.jp/admin-page-framework/
8
 * Copyright (c) 2013-2015 Michael Uno; Licensed GPLv2
9
 * 
10
 */
11
12
/**
13
 * Adds a tab of the set page to the loader plugin.
14
 * 
15
 * @since       3.5.0    
16
 * @since       3.5.3       Extends `AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase`.
17
 * @extends     AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase
18
 */
19
class AdminPageFrameworkLoader_AdminPage_Help_Tip extends AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase {
2 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style introduced by
As per PSR2, the opening brace for this class should be on a new line.
Loading history...
20
   
21
    /**
22
     * Triggered when the tab is loaded.
23
     */
24
    public function replyToLoadTab( $oAdminPage ) {
25
            
26
        $_aItems     = $this->getContentsByHeader( $this->getReadmeContents(), 4 );
27
        $_iLastIndex = count( $_aItems ) - 1;
28
        foreach( $_aItems as $_iIndex => $_aContent ) {
29
30
            $_oParser   = new AdminPageFramework_WPReadmeParser( $_aContent[ 1 ] );
31
            $_sContent  = $_oParser->get();
32
            $oAdminPage->addSettingSections(    
33
                $this->sPageSlug, // the target page slug  
34
                array(
35
                    'section_id'        => 'tips_' . $_iIndex,
36
                    'title'             => $_aContent[ 0 ],
37
                    'collapsible'       => array(
38
                        'toggle_all_button' => $_iLastIndex === $_iIndex 
39
                            ? array( 'bottom-right' )
40
                            : ( 0 === $_iIndex
41
                                ? array( 'top-right' )
42
                                : false
43
                            ),
44
                    ),
45
                    'content'           => $_sContent,
46
                            
47
                )
48
            );              
49
            
50
        }        
51
52
    }
53
        /**
54
         * @return      string
55
         */
56
        private function getReadMeContents()  {       
57
            return $this->_getReadmeContents( 
58
                AdminPageFrameworkLoader_Registry::$sDirPath . '/readme.txt', // source path
59
                '', // TOC title
60
                array( 'Other Notes' )  // sections
61
            );
62
63
        }   
64
    
65
}
1 ignored issue
show
Coding Style introduced by
According to PSR2, the closing brace of classes should be placed on the next line directly after the body.

Below you find some examples:

// Incorrect placement according to PSR2
class MyClass
{
    public function foo()
    {

    }
    // This blank line is not allowed.

}

// Correct
class MyClass
{
    public function foo()
    {

    } // No blank lines after this line.
}
Loading history...