plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in AnotherSteempress_Loader as all of the hooks are defined * in that particular class. * * The AnotherSteempress_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/anothersteempress-admin.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in AnotherSteempress_Loader as all of the hooks are defined * in that particular class. * * The AnotherSteempress_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/anothersteempress-admin.js', array( 'jquery' ), $this->version, false ); } /** * Register the administration menu for this plugin into the WordPress Dashboard menu. * * @since 1.0.0 */ public function add_plugin_admin_menu() { add_options_page( 'AnotherSteempress Options', 'AnotherSteempress', 'manage_options', $this->plugin_name, array($this, 'display_plugin_setup_page') ); } /** * Add settings action link to the plugins page. * * @since 1.0.0 */ public function add_action_links( $links ) { /* * Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name) */ $settings_link = array( '' . __('Settings', $this->plugin_name) . '', ); return array_merge( $settings_link, $links ); } /** * Render the settings page for this plugin. * * @since 1.0.0 */ public function display_plugin_setup_page() { include_once('partials/anothersteempress-admin-display.php'); } public function validate($input) { // All checkboxes inputs //return $input; $valid = array(); $valid['reward'] = (isset($input['reward']) && !empty($input['reward'] ) && ($input['reward'] == "50" || $input['reward'] == "100")) ? $input['reward'] : "50"; $valid['posting-key'] = (isset($input['posting-key']) && !empty($input['posting-key'])) ? htmlspecialchars($input['posting-key'], ENT_QUOTES) : ""; $valid['tags'] = (isset($input['tags']) && !empty($input['tags'])) ? htmlspecialchars($input['tags'], ENT_QUOTES) : ""; $valid['username'] = (isset($input['username']) && !empty($input['username'])) ? htmlspecialchars($input['username'], ENT_QUOTES) : ""; $valid['seo'] = ((isset($input['seo']) && !empty($input['seo'])) && $input['seo'] == 'on') ? 'on' : "off"; $valid['use-testnet'] = ((isset($input['use-testnet']) && !empty($input['use-testnet'])) && $input['use-testnet'] == 'yes') ? 'yes' : "no"; $valid['vote'] = ((isset($input['vote']) && !empty($input['vote'])) && $input['vote'] == 'on') ? 'on' : "off"; $valid['testnet-posting-key'] = (isset($input['testnet-posting-key']) && !empty($input['testnet-posting-key'])) ? htmlspecialchars($input['testnet-posting-key'], ENT_QUOTES) : ""; $valid['testnet-username'] = (isset($input['testnet-username']) && !empty($input['testnet-username'])) ? htmlspecialchars($input['testnet-username'], ENT_QUOTES) : ""; $valid['category'] = (isset($input['category']) && !empty($input['category'])) ? htmlspecialchars($input['category'], ENT_QUOTES) : ""; if ($valid['tags'] == "" || $valid['username'] == "" || $valid['posting-key'] == "" || $valid['category'] != "") { $this->AnotherSteempress_addnotice("error","Required fields missing. Please check your configuration."); } $valid['template'] = html_entity_decode($input["template"]); $valid['testnet-authvalid'] = (isset($input['testnet-authvalid']) && $input['testnet-authvalid'] == 'yes') ? 'yes' : 'no'; $valid['live-authvalid'] = (isset($input['live-authvalid']) && $input['live-authvalid'] == 'yes') ? 'yes' : 'no'; if (extension_loaded('tidy')) { $templatehtml=$valid['template']; $tidy = new tidy(); $tidy->parseString($templatehtml,Array('indent'=>true)); $templatehtml=trim($tidy->body()); $templatehtml = preg_replace('/(
)/','',$templatehtml); $templatehtml = preg_replace('/(<\/body>)/','',$templatehtml); $valid['template']=$templatehtml; } return $valid; } public function options_update() { register_setting($this->plugin_name, $this->plugin_name, array($this, 'validate')); } public function update_user_profile() { $userid=get_current_user_id(); $options = $this->validate($_POST[$this->plugin_name]); $testnetdata = array("body" => array("testnet" => "yes","author" => $options["testnet-username"],"wif"=>$options["testnet-posting-key"])); $steemdata = array("body" => array("testnet" => "no","author" => $options["username"],"wif"=>$options["posting-key"])); $testnetresult = wp_remote_post("https://steempress.dm42.net/spress/testuser", $testnetdata); $steemresult = wp_remote_post("https://steempress.dm42.net/spress/testuser", $steemdata); $options["live-authvalid"]="no"; if (is_array($steemresult) or ($steemresult instanceof Traversable)) { $steemresults = json_decode($steemresult["body"],true); if (isset($steemresults["result"]) && $steemresults["result"] == "success") { $options["live-authvalid"]="yes"; } } $options["testnet-authvalid"]="no"; if (is_array($testnetresult) or ($testnetresult instanceof Traversable)) { $testnetresults = json_decode($testnetresult["body"],true); if (isset($testnetresults["result"]) && $testnetresults["result"] == "success") { $options["testnet-authvalid"]="yes"; } } update_user_meta($userid,$this->plugin_name,$options); } public function display_user_profile_opts() { include "partials/anothersteempress-useropts-display.php"; } public function AnotherSteempress_addnotice($type,$notice) { global $AnotherSteempress_notices; if (!is_array($AnotherSteempress_notices)) { $AnotherSteempress_notices = Array(); } $newnotice=Array('type'=>$type,'notice'=>$notice); array_push($AnotherSteempress_notices,$newnotice); } public function AnotherSteempress_displaynotices() { global $AnotherSteempress_notices; $content = ''; if (!is_array($AnotherSteempress_notices)) return; foreach ($AnotherSteempress_notices as $notice) { $content .= ''.$notice['notice'].'
'; $content .= '