function __construct() { // setting plugin meta saved in config.php $this->plugin_meta = get_plugin_meta(); // getting saved settings $this->plugin_settings = get_option($this->plugin_meta['shortname'] . '_settings'); // file upload dir name $this->contact_files = 'contact_files'; // this will hold form form_id $this->form_id = ''; /* * [2] TODO: update scripts array for SHIPPED scripts only use handlers */ // setting shipped scripts $this->wp_shipped_scripts = array('jquery', 'jquery-ui-datepicker'); $is_html5 = 0; /* * [3] TODO: update scripts array for custom scripts/styles */ // setting plugin settings if ($is_html5 == 1) { $this->plugin_scripts = array(array('script_name' => 'scripts', 'script_source' => '/js/script.js', 'localized' => true, 'type' => 'js'), array('script_name' => 'upload_plugin', 'script_source' => '/js/upload.js', 'localized' => true, 'type' => 'js'), array('script_name' => 'uploadifive', 'script_source' => '/js/uploadifive-v1.1.1/jquery.uploadifive.min.js', 'localized' => false, 'type' => 'js'), array('script_name' => 'uploadifive_css', 'script_source' => '/js/uploadifive-v1.1.1/uploadifive.css', 'localized' => false, 'type' => 'style'), array('script_name' => 'styles', 'script_source' => '/plugin.styles.css', 'localized' => false, 'type' => 'style'), array('script_name' => 'nm-ui-style', 'script_source' => '/js/ui/css/smoothness/jquery-ui-1.10.3.custom.min.css', 'localized' => false, 'type' => 'style', 'page_slug' => array('nm-new-form'))); } else { $this->plugin_scripts = array(array('script_name' => 'scripts', 'script_source' => '/js/script.js', 'localized' => true, 'type' => 'js'), array('script_name' => 'upload_plugin', 'script_source' => '/js/upload.js', 'localized' => true, 'type' => 'js'), array('script_name' => 'uploadify', 'script_source' => '/js/uploadify-v-3-1-1/jquery.uploadify-3.1.min.js', 'localized' => false, 'type' => 'js'), array('script_name' => 'uploadify_css', 'script_source' => '/js/uploadify-v-3-1-1/uploadify.css', 'localized' => false, 'type' => 'style'), array('script_name' => 'styles', 'script_source' => '/plugin.styles.css', 'localized' => false, 'type' => 'style'), array('script_name' => 'nm-ui-style', 'script_source' => '/js/ui/css/smoothness/jquery-ui-1.10.3.custom.min.css', 'localized' => false, 'type' => 'style', 'page_slug' => array('nm-new-form'))); } /* * [4] Localized object will always be your pluginshortname_vars e.g: pluginshortname_vars.ajaxurl */ $this->localized_vars = array('ajaxurl' => admin_url('admin-ajax.php'), 'plugin_url' => $this->plugin_meta['url'], 'doing' => $this->plugin_meta['url'] . '/images/loading.gif', 'settings' => $this->plugin_settings, 'file_upload_path_thumb' => $this->get_file_dir_url(true), 'file_upload_path' => $this->get_file_dir_url(), 'file_meta' => '', 'section_slides' => '', 'is_html5' => $is_html5); /* * [5] TODO: this array will grow as plugin grow all functions which need to be called back MUST be in this array setting callbacks */ // following array are functions name and ajax callback handlers $this->ajax_callbacks = array('save_settings', 'save_form_meta', 'update_form_meta', 'send_form_data', 'upload_file', 'delete_file', 'delete_meta', 'save_edited_photo'); /* * plugin localization being initiated here */ add_action('init', array($this, 'wpp_textdomain')); /* * plugin main shortcode if needed */ add_shortcode('nm-wp-contact', array($this, 'render_shortcode_template')); /* * hooking up scripts for front-end */ add_action('wp_enqueue_scripts', array($this, 'load_scripts')); /* * registering callbacks */ $this->do_callbacks(); /* * add custom post type support if enabled */ add_action('init', array($this, 'enable_custom_post')); }
function __construct() { // setting plugin meta saved in config.php $this->plugin_meta = get_plugin_meta(); // getting saved settings $this->plugin_settings = get_option($this->plugin_meta['shortname'] . '_settings'); // file upload dir name $this->contact_files = 'contact_files'; /* * [1] TODO: change this for plugin admin pages */ $this->menu_pages = array(array('page_title' => $this->plugin_meta['name'], 'menu_title' => $this->plugin_meta['name'], 'cap' => 'edit_plugins', 'slug' => $this->plugin_meta['shortname'], 'callback' => 'main_settings', 'parent_slug' => ''), array('page_title' => 'Create Forms', 'menu_title' => 'CreateForms', 'cap' => 'edit_plugins', 'slug' => 'nm-create-form', 'callback' => 'forms_list', 'parent_slug' => $this->plugin_meta['shortname'])); /* * [2] TODO: Change this for admin related scripts JS scripts and styles to loaded ADMIN */ $this->plugin_scripts_admin = array(array('script_name' => 'scripts-global', 'script_source' => '/js/nm-global.js', 'localized' => false, 'type' => 'js', 'page_slug' => $this->plugin_meta['shortname']), array('script_name' => 'scripts-admin', 'script_source' => '/js/admin.js', 'localized' => true, 'type' => 'js', 'page_slug' => array($this->plugin_meta['shortname'], 'nm-create-form', 'nm-new-form'), 'depends' => array('jquery', 'jquery-ui-accordion', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-slider', 'jquery-ui-dialog', 'jquery-ui-tabs')), array('script_name' => 'ui-style', 'script_source' => '/js/ui/css/smoothness/jquery-ui-1.10.3.custom.min.css', 'localized' => false, 'type' => 'style', 'page_slug' => array('nm-new-form')), array('script_name' => 'plugin-css', 'script_source' => '/templates/admin/style.css', 'localized' => false, 'type' => 'style', 'page_slug' => array($this->plugin_meta['shortname'], 'nm-new-form'))); add_action('admin_menu', array($this, 'add_menu_pages')); add_action('admin_init', array($this, 'init_admin')); }