AnsPress_Admin::ap_addon_options()
Description #
Load addons options form in a thickbox.
Source #
File: admin/anspress-admin.php
public static function ap_addon_options() {
// Bail if no permission.
if ( ! current_user_can( 'manage_options' ) ) {
exit;
}
define( 'IFRAME_REQUEST', true );
iframe_header();
wp_enqueue_style( 'anspress-main', ap_get_theme_url( 'css/main.css' ), array(), AP_VERSION );
wp_enqueue_style( 'ap-admin-css', ANSPRESS_URL . 'assets/ap-admin.css', array(), AP_VERSION );
wp_enqueue_style( 'anspress-fonts', ap_get_theme_url( 'css/fonts.css' ), array(), AP_VERSION );
?>
<script type="text/javascript">
currentQuestionID = '<?php the_ID(); ?>';
apTemplateUrl = '<?php echo esc_url( ap_get_theme_url( 'js-template', false, false ) ); ?>';
aplang = {};
apShowComments = false;
removeImage = '<?php esc_attr_e( 'Remove image', 'anspress-question-answer' ); ?>';
</script>
<?php
wp_enqueue_script( 'anspress-question' );
wp_enqueue_script( 'anspress-ask' );
wp_enqueue_script( 'anspress-list' );
wp_enqueue_script( 'anspress-notifiactions' );
wp_enqueue_script( 'anspress-admin-js' );
$addon = ap_get_addon( ap_sanitize_unslash( 'addon', 'r' ) );
$from_args = array(
'form_action' => admin_url( 'admin.php?action=ap_save_addon_options&active_addon=' . $addon['id'] ),
'ajax_submit' => false,
);
/**
* Filter AnsPress add-on options form.
*
* @param array $form_args Array for form arguments.
* @since 4.1.0
*/
$form_args = apply_filters( 'ap_addon_form_args', $from_args );
$form_name = str_replace( '.php', '', $addon['id'] );
$form_name = str_replace( '/', '_', $form_name );
echo '<div class="ap-thickboxw">';
// Show updated notice.
if ( ap_isset_post_value( 'updated' ) === '1' ) {
echo '<div class="notice notice-success is-dismissible">';
echo '<p>' . esc_html__( 'Addon options updated successfully!', 'anspress-question-answer' ) . '</p>';
echo '</div>';
}
if ( anspress()->form_exists( 'addon-' . $form_name ) ) {
anspress()->get_form( 'addon-' . $form_name )->generate( $form_args );
} else {
echo '<p class="ap-form-nofields">';
// translators: %s is name of wp hook.
echo esc_attr( sprintf( __( 'There is no option registered by this addon. Custom options can be registered by using hook: %s', 'anspress-question-answer' ), 'ap_form_addon-' . $form_name ) );
echo '</p>';
}
echo '</div>';
iframe_footer();
exit;
}
Expand full source code Collapse full source code View on GitHub: admin/anspress-admin.php:1444
Add your comment