function bap_plugin_initialize_options() { if (false == get_option('bap_plugin_options')) { add_option('bap_plugin_options', apply_filters('bap_plugin_default_options', bap_plugin_default_options())); } // Settings section ------------------------------------------------------------------------------------------------------------------------- add_settings_section('bap_basesettings', __('', 'bento_ajaxPagin'), 'bap_jslib_callback', 'bap_plugin_options'); // Settings section callback --------------------------------------- function bap_jslib_callback() { echo '<p>' . __('', 'bento_ajaxPagin') . '</p>'; } // Setting fields --------------------------------------- add_settings_field('bap_bentoScripts', 'Have you already included Tappy-js?', 'bap_bentoScripts_callback', 'bap_plugin_options', 'bap_basesettings', array(__('<strong>Yes I have</strong> — please do not enqueue <a href="https://github.com/filamentgroup/tappy">Tappy</a> again', 'bento_ajaxPagin'))); add_settings_field('bap_loopContainer', 'ID for the container that wrap posts:', 'bap_loopContainer_callback', 'bap_plugin_options', 'bap_basesettings', array(__('(Omit #. If id="listofposts" just put <em>listofposts</em>.)', 'bento_ajaxPagin'))); add_settings_field('bap_loopedItem', 'Class for container that wraps each post (This field is optional)', 'bap_loopedItem_callback', 'bap_plugin_options', 'bap_basesettings', array(__('(If class="post" just put <em>post</em>.)', 'bento_ajaxPagin'))); add_settings_field('bap_buttonText', 'Button text:', 'bap_buttonText_callback', 'bap_plugin_options', 'bap_basesettings', array(__('Default text: <em>Load new posts</em>', 'bento_ajaxPagin'))); add_settings_field('bap_loadingText', 'Button-is-loading-text:', 'bap_loadingText_callback', 'bap_plugin_options', 'bap_basesettings', array(__('Default text: <em>Loading…</em>', 'bento_ajaxPagin'))); // Setting fields callbacks --------------------------------------- function bap_bentoScripts_callback($args) { $options = get_option('bap_plugin_options'); $html = '<input type="checkbox" id="bap_bentoScripts" name="bap_plugin_options[bap_bentoScripts]" value="1" ' . checked(1, isset($options['bap_bentoScripts']) ? $options['bap_bentoScripts'] : 0, false) . '/>'; $html .= '<label for="bap_bentoScripts"> ' . $args[0] . '</label>'; echo $html; } function bap_loopContainer_callback($args) { $options = get_option('bap_plugin_options'); $html = '<input type="text" id="bap_loopContainer" name="bap_plugin_options[bap_loopContainer]" value="' . $options['bap_loopContainer'] . '" />'; $html .= '<label for="bap_loopContainer"> ' . $args[0] . '</label>'; echo $html; } function bap_loopedItem_callback($args) { $options = get_option('bap_plugin_options'); $html = '<input type="text" id="bap_loopedItem" name="bap_plugin_options[bap_loopedItem]" value="' . $options['bap_loopedItem'] . '" />'; $html .= '<label for="bap_loopedItem"> ' . $args[0] . '</label>'; echo $html; } function bap_buttonText_callback($args) { $options = get_option('bap_plugin_options'); $html = '<input type="text" id="bap_buttonText" name="bap_plugin_options[bap_buttonText]" value="' . $options['bap_buttonText'] . '" />'; $html .= '<label for="bap_buttonText"> ' . $args[0] . '</label>'; echo $html; } function bap_loadingText_callback($args) { $options = get_option('bap_plugin_options'); $html = '<input type="text" id="bap_loadingText" name="bap_plugin_options[bap_loadingText]" value="' . $options['bap_loadingText'] . '" />'; $html .= '<label for="bap_loadingText"> ' . $args[0] . '</label>'; echo $html; } // Register and sanitize ------------------------------------------------------------------------------------------------------------------------- register_setting('bap_plugin_options', 'bap_plugin_options', 'bap_validate_sanitize_input'); }
function bap_next_posts_link() { global $wp_query; if (empty(bap_get_option_text('bap_buttonText'))) { $optionsDefault = bap_plugin_default_options(); $buttonText = $optionsDefault['bap_buttonText']; } else { $buttonText = bap_get_option_text('bap_buttonText'); } next_posts_link($buttonText, $wp_query->max_num_pages); }