'array', 'sanitize_callback' => 'autopost_sanitize_options', ) ); add_settings_section( 'autopost_main_section', __('تنظیمات عمومی پابلیکا', 'autopost'), function () { echo '
' . esc_html__('تنظیمات اتصال و انتشار رپورتاژ', 'autopost') . '
'; echo '' . esc_html__('لطفا جهت اتصال افزونه اتوپست به پنل پابلیکا ، ابتدا پلن رپورتاژی که قصد انتشار سریع برای آن را دارید انتخاب نموده و همچنین دسته بندی انتشار را انتخاب نمایید و ذخیره کنید', 'autopost') . '
'; }, 'autopost_options_page' ); add_settings_field('reportage_plan', __('انتخاب پلن رپورتاژ', 'autopost'), function () { $options = get_option('autopost_options', []); $value = isset($options['reportage_plan']) ? $options['reportage_plan'] : ''; echo 'اگر برای منتشر شدن رپورتاژآگهی در سایت خود توسط افزونه ، نیاز به بازبینی و تایید دستی محتوا در پنل پابلیکا قبل از انتشار دارید، این گزینه را انتخاب کنید.
'; }, 'autopost_options_page', 'autopost_main_section'); } /** * Add settings page */ function autopost_add_settings_page() { add_options_page( __('تنظیمات پابلیکا', 'autopost'), __('پابلیکا', 'autopost'), 'manage_options', 'autopost-options', 'autopost_render_settings_page' ); } /** * Redirect to plugin settings page right after activation */ function autopost_maybe_redirect_to_autopost_settings() { // Only run in admin, non-ajax, non-cron, non-rest, with capability if ( ! is_admin() ) { return; } if ( defined('DOING_AJAX') && DOING_AJAX ) { return; } if ( defined('DOING_CRON') && DOING_CRON ) { return; } if ( defined('REST_REQUEST') && REST_REQUEST ) { return; } if ( is_network_admin() ) { return; // avoid network admin context } if ( isset($_GET['activate-multi']) ) { return; // skip bulk activation } if ( ! current_user_can('manage_options') ) { return; } $flag = get_option('autopost_plugin_activated'); if ( $flag ) { delete_option('autopost_plugin_activated'); $target = admin_url('options-general.php?page=autopost-options'); wp_safe_redirect($target); exit; } } /** * Enqueue admin assets */ function autopost_admin_enqueue_assets($hook_suffix) { if ($hook_suffix !== 'settings_page_autopost-options') { return; } // Enqueue Select2 for the reportage plan field wp_enqueue_script('select2', AUTOPOST_PLUGIN_URL . 'assets/js/select2.min.js', ['jquery'], '4.1.0-rc.0', true); wp_enqueue_style('select2', AUTOPOST_PLUGIN_URL . 'assets/css/select2.min.css', [], '4.1.0-rc.0'); wp_enqueue_style('autopost-admin-css', AUTOPOST_PLUGIN_URL . 'assets/css/autopost-admin.css', [], AUTOPOST_VERSION); $handle = 'autopost-admin-js'; $src = AUTOPOST_PLUGIN_URL . 'assets/js/autopost-admin.js'; wp_enqueue_script($handle, $src, ['jquery', 'select2'], AUTOPOST_VERSION, true); $panel_domain = defined('AUTOPOST_PANEL_DOMAIN') ? AUTOPOST_PANEL_DOMAIN : 'panel.publica.ir'; $options = get_option('autopost_options', []); wp_localize_script($handle, 'AUTOPOSTAdmin', [ 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('autopost_admin_ajax'), 'panelDomain' => $panel_domain, 'websiteUrl' => AUTOPOST_WEBSITE_URL, 'savedPlanCategory' => isset($options['plan_category']) ? $options['plan_category'] : '', ]); } /** * Render settings page */ function autopost_render_settings_page() { if (!current_user_can('manage_options')) { return; } ?>