getReadMeContents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
ccs 0
cts 5
cp 0
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://admin-page-framework.michaeluno.jp/
8
 * Copyright (c) 2013-2022, 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
 */
17
class AdminPageFrameworkLoader_AdminPage_Help_Example extends AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase {
18
19
    /**
20
     * Triggered when the tab is loaded.
21
     */
22
    public function replyToLoadTab( $oAdminPage ) {
23
24
        $_aItems     = $this->getContentsByHeader( $this->getReadmeContents(), 3 );
25
        $_iLastIndex = count( $_aItems ) - 1;
26
        foreach( $_aItems as $_iIndex => $_aContent ) {
27
28
            $_oParser   = new AdminPageFramework_WPReadmeParser;
29
            $_oParser->setText( $_aContent[ 1 ] );
30
            $_sContent  = $_oParser->get();
31
            $oAdminPage->addSettingSections(
32
                $this->sPageSlug, // the target page slug
33
                array(
34
                    'section_id'        => 'examples_' . $_iIndex,
35
                    'title'             => $_aContent[ 0 ],
36
                    'collapsible'       => array(
37
                        'toggle_all_button' => $_iLastIndex === $_iIndex
38
                            ? array( 'bottom-right' )
39
                            : ( 0 === $_iIndex
40
                                ? array( 'top-right' )
41
                                : false
42
                            ),
43
                    ),
44
                    'content'           => $_sContent,
45
46
                )
47
            );
48
49
        }
50
51
    }
52
        /**
53
         * @return      string
54
         */
55
        private function getReadMeContents()  {
56
            return $this->_getReadmeContents(
57
                AdminPageFrameworkLoader_Registry::$sDirPath . '/asset/text/examples.txt',
58
                '',
59
                array( 'Examples' )
60
            );
61
        }
62
63
}
64