예제 #1
0
파일: helpers.php 프로젝트: QuezonMe/skelet
 /**
  * Prints or returns an input field
  */
 static function textarea($name)
 {
     // $params
     if (func_num_args() > 1) {
         $params = func_get_arg(1);
     }
     if (!is_array($params)) {
         $params = array();
     }
     // $args
     if (func_num_args() > 2) {
         $args = func_get_arg(2);
     }
     if (!is_array($args)) {
         $args = array();
     }
     // Load defaults
     $params += array('id' => '');
     // Add name
     $params['name'] = $name;
     // Set $value
     $value = empty($args['value']) ? '' : $args['value'];
     // Build textarea html
     if (K::get_var('editor', $args)) {
         // Remove the name since it's attached to the editor
         $params_for_editor = $params;
         unset($params_for_editor['name']);
         // Build
         ob_start();
         wp_editor($value, str_replace(array('[', ']'), '_', $name) . mt_rand(100, 999), array('editor_height' => K::get_var('editor_height', $args), 'media_buttons' => K::get_var('media_buttons', $args, TRUE), 'teeny' => K::get_var('teeny', $args), 'textarea_name' => $name, 'textarea_rows' => K::get_var('textarea_rows', $args, 20)));
         $textarea = ob_get_clean();
         $textarea = sprintf('<div %s>%s</div>', K::params_str($params_for_editor), $textarea);
     } else {
         $textarea = sprintf('<textarea %s>%s</textarea>', K::params_str($params), $value);
     }
     // Format
     if (!empty($args['format'])) {
         $textarea = str_replace(array(':textarea', ':value', ':name', ':id'), array($textarea, $value, $name, $params['id']), $args['format']);
     }
     // Print or return the textarea field HTML
     if (!empty($args['return'])) {
         return $textarea;
     } else {
         echo $textarea;
     }
 }
예제 #2
0
/**
 * Show message when options are saved successfully
 * 
 * Seeks in this order: tab > page > default
 */
function paf_notice()
{
    global $paf_pages, $paf_tabs, $paf_page, $paf_tab;
    // Look in tab configuration
    if ($paf_tab && ($message = K::get_var('success', $paf_tabs[$paf_tab]))) {
    } else {
        if ($message = K::get_var('success', $paf_pages[$paf_page])) {
        } else {
            $message = __('Settings saved.');
        }
    }
    printf('<div class="updated"><p>%s</p></div>', $message);
}
function paf_print_option_type_not_implemented($option_def)
{
    $option_id = key($option_def);
    $option = $option_def[$option_id];
    if ('~' === K::get_var('description', $option)) {
        $option['description'] = paf_option_return_dump($option_id);
    }
    K::input('paf[' . $option_id . ']', array('value' => K::get_var('value', $option, '')), array('format' => sprintf(paf_option_return_format(), paf_option_return_title($option_def), sprintf('<p class="description"><span class="dashicons dashicons-no"></span> ' . __('The option type <code>%s</code> is not yet implemented') . '</p>', $option['type']), K::get_var('description', $option, ''))));
}
/**
 * Callback function for pages
 */
function paf_page_cb()
{
    global $paf;
    global $paf_options, $paf_pages, $paf_sections, $paf_tabs;
    global $paf_page_tabs, $paf_page_sections, $paf_page_options;
    global $paf_page, $paf_tab;
    // Get submit button text (looks in: tab > page > default )
    if ($paf_tab && ($submit_button_text = K::get_var('submit_button', $paf_page_tabs[$paf_tab]))) {
    } else {
        if ($submit_button_text = K::get_var('submit_button', $paf_pages[$paf_page])) {
        } else {
            $submit_button_text = __('Save Changes');
        }
    }
    // Get reset button text (looks in: tab > page )
    if ($paf_tab && ($reset_button_text = K::get_var('reset_button', $paf_page_tabs[$paf_tab]))) {
    } else {
        if ($reset_button_text = K::get_var('reset_button', $paf_pages[$paf_page])) {
        }
    }
    // Start output
    echo '<div class="wrap">' . '<h2>' . K::get_var('title', $paf_pages[$paf_page], $paf_page) . '</h2>';
    // Print tabs links
    if ($paf_page_tabs) {
        echo '<h2 class="nav-tab-wrapper">';
        foreach ($paf_page_tabs as $slug => $page_tab) {
            printf('<a href="?page=%s&amp;tab=%s" class="nav-tab %s">%s</a>', $paf_page, $slug, $paf_tab === $slug ? 'nav-tab-active' : '', $page_tab['menu_title']);
        }
        echo '</h2>';
        echo '<h2>' . $paf_page_tabs[$paf_tab]['title'] . '</h2>';
    }
    // Print the options
    echo '<form id="paf-form" class="hidden" action="' . paf_url() . '" method="post">';
    // Show options that don't have sections
    reset($paf_page_options);
    foreach ($paf_page_options as $id => $page_option) {
        if (K::get_var('section', $page_option)) {
            continue;
        }
        paf_print_option($id);
    }
    // Show options that have sections
    reset($paf_page_options);
    foreach ($paf_page_sections as $section_id => $page_section) {
        K::wrap(K::get_var('title', $page_section, $section_id), array('class' => 'title'), array('in' => 'h3'));
        foreach ($paf_page_options as $id => $page_option) {
            if ($section_id === K::get_var('section', $page_option)) {
                paf_print_option($id);
            }
        }
    }
    // Nonce
    wp_nonce_field('paf_save', 'paf_nonce');
    // Submit and Reset buttons
    echo '<p>';
    K::input('paf_submit', array('class' => 'button button-large button-primary', 'href' => '#', 'id' => 'paf-submit', 'type' => 'submit', 'value' => $submit_button_text), array('in' => 'input'));
    if ($reset_button_text) {
        echo ' ';
        K::wrap('Reset', array('class' => 'button button-large paf-reset', 'href' => '#', 'id' => 'paf-reset'), array('in' => 'a'));
    }
    echo '</p>';
    echo '</form>';
    // Add JS and CSS
    paf_asset_js('paf', TRUE);
    paf_asset_css('paf', TRUE);
    echo '</div>';
}
function skelet_process_shortcodes()
{
    foreach (K::get_var('paf_shortcodes', $GLOBALS, array()) as $tag => $specs) {
        // Get func
        $func = K::get_var('func', $specs);
        if (!function_exists($func)) {
            $func = $tag . '_func';
            if (!function_exists($func)) {
                $func = $tag;
                if (!function_exists($func)) {
                    $func = 'skelet_func';
                }
            }
        }
        // bind
        add_shortcode($tag, $func);
    }
}
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
/**
* @file
* Main file of the "PressApps Plugin Framework"
* 
* The file loads the core files if not already done inside another plugin,
* then it loads the options defined in the options folder.
* 
* @package pressapps-admin-framework
*/
/**
 * Load the framework core if not done inside another plugin
 */
if (!defined('PAF')) {
    include dirname(__FILE__) . '/core/core.php';
}
/**
 * Use sample data if $skelet_use_sample_data evaluates to true
 */
if (K::get_var('skelet_use_sample_data')) {
    skelet_dir(dirname(__FILE__) . '/sample-data/');
}