plugin_slug = $plugin_slug; $this->version = $version; $this->option_name = $option_name; $this->settings = get_option($this->option_name); $this->settings_group = $this->option_name . '_group'; } /** * Generate settings fields by passing an array of data (see the render method). * * @param array $field_args The array that helps build the settings fields * @param array $settings The settings array from the options table * * @return string The settings fields' HTML to be output in the view */ private function aic_custom_settings_fields($field_args, $settings) { $output = '
'; if (isset($settings['aic_ad_title'])) { foreach ($settings['aic_ad_title'] as $key => $value) { $output .= '

' . $value . '

' . __('Ad Title', 'ads-in-content') . '
' . __('Ad Code', 'ads-in-content') . '
' . __('Delete', 'ads-in-content') . '
'; } } $output .= '
' . __('Add New Ad', 'ads-in-content') . '
'; return $output; } public function aic_adblock_notice() { ?>

Ads In Content

It seems like your AdBlocker is conflicting with the plugin. Please add your domain to whitelist or close AdBlocker.

plugin_slug . '-adblocker-removal', plugin_dir_url(__FILE__) . 'js/aic-adblocker-removal.js', ['jquery'], $this->version, true); } public function aic_register_settings() { register_setting($this->settings_group, $this->option_name); } public function aic_render_block($attributes) { $adCode = $this->settings['aic_ad_code'][$attributes['adKey']]; $html = '
' . $adCode . '
'; return $html; } public function aic_get_current_count() { echo intval(get_option('aic_block_count')); wp_die(); } public function aic_count_increase() { $count = intval(get_option('aic_block_count')) + 1; update_option('aic_block_count', $count); } public function aic_register_block() { wp_register_script( 'ads-in-content-block', plugins_url('block.build.js', __FILE__), array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'wp-components') ); register_block_type('aic/block', array( 'editor_script' => 'ads-in-content-block', 'render_callback' => [$this, 'aic_render_block'] )); wp_localize_script('ads-in-content-block', 'ad_list', $this->settings); } public function aic_add_menus() { $plugin_name = Info::get_plugin_title(); add_submenu_page( 'options-general.php', $plugin_name, $plugin_name, 'manage_options', $this->plugin_slug, [$this, 'aic_render'] ); } /** * Render the view using MVC pattern. */ public function aic_render() { if (!get_option('aic_block_count')) { update_option('aic_block_count', 0); } wp_localize_script($this->plugin_slug, 'aic_block_count', array('ajax_url' => admin_url('admin-ajax.php'))); $cssCode = wp_remote_get(plugin_dir_url(__FILE__) . 'css/aic-admin.css'); $jsCode = wp_remote_get(plugin_dir_url(__FILE__) . 'js/aic-admin.js'); echo ''; echo ''; // Generate the settings fields $field_args = [ [ 'label' => 'aic_ad_title', 'slug' => 'aic_ad_title', 'type' => 'text' ], [ 'label' => 'aic_ad_code', 'slug' => 'aic_ad_code', 'type' => 'textarea' ] ]; // Model $settings = $this->settings; // Controller $fields = $this->aic_custom_settings_fields($field_args, $settings); $settings_group = $this->settings_group; $heading = Info::get_plugin_title(); $submit_text = esc_attr__('Submit', 'ads-in-content'); // View require_once plugin_dir_path(dirname(__FILE__)) . 'admin/partials/view.php'; } }