public static function posting() { ?> <div class="wrap"> <?php // Use this to add a new page. To bulk change pages click on the "Manage" tab. do_action("mainwp_bulkpage_before_post", $_GET['id']); $skip_post = false; if (isset($_GET['id'])) { if ('yes' == get_post_meta($_GET['id'], '_mainwp_skip_posting', true)) { $skip_post = true; wp_delete_post($_GET['id'], true); } } if (!$skip_post) { //Posts the saved sites if (isset($_GET['id'])) { $id = $_GET['id']; $post = get_post($id); if ($post) { $selected_by = get_post_meta($id, '_selected_by', true); $selected_sites = unserialize(base64_decode(get_post_meta($id, '_selected_sites', true))); $selected_groups = unserialize(base64_decode(get_post_meta($id, '_selected_groups', true))); $post_slug = base64_decode(get_post_meta($id, '_slug', true)); $post_custom = get_post_custom($id); include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; $post_featured_image = get_post_thumbnail_id($id); $mainwp_upload_dir = wp_upload_dir(); $new_post = array('post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_date' => $post->post_date, 'post_date_gmt' => $post->post_date_gmt, 'post_type' => 'page', 'post_name' => $post_slug, 'post_excerpt' => $post->post_excerpt, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'id_spin' => $post->ID); if ($post_featured_image != null) { //Featured image is set, retrieve URL $img = wp_get_attachment_image_src($post_featured_image, 'full'); $post_featured_image = $img[0]; } $dbwebsites = array(); if ($selected_by == 'site') { //Get all selected websites foreach ($selected_sites as $k) { if (MainWPUtility::ctype_digit($k)) { $website = MainWPDB::Instance()->getWebsiteById($k); $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } } } else { //Get all websites from the selected groups foreach ($selected_groups as $k) { if (MainWPUtility::ctype_digit($k)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->sync_errors != '') { continue; } $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } @MainWPDB::free_result($websites); } } } $output = new stdClass(); $output->ok = array(); $output->errors = array(); $startTime = time(); if (count($dbwebsites) > 0) { $post_data = array('new_post' => base64_encode(serialize($new_post)), 'post_custom' => base64_encode(serialize($post_custom)), 'post_featured_image' => base64_encode($post_featured_image), 'mainwp_upload_dir' => base64_encode(serialize($mainwp_upload_dir))); $post_data = apply_filters("mainwp_bulkpage_posting", $post_data, $id); MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newpost', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output); } $failed_posts = array(); foreach ($dbwebsites as $website) { if ($output->ok[$website->id] == 1 && isset($output->added_id[$website->id])) { do_action('mainwp-post-posting-page', $website, $output->added_id[$website->id], isset($output->link[$website->id]) ? $output->link[$website->id] : null); do_action('mainwp-bulkposting-done', $post, $website, $output); } else { $failed_posts[] = $website->id; } } $del_post = true; $saved_draft = get_post_meta($id, "_saved_as_draft", true); if ($saved_draft == "yes") { if (count($failed_posts) > 0) { $del_post = false; update_post_meta($post->ID, "_selected_sites", base64_encode(serialize($failed_posts))); update_post_meta($post->ID, "_selected_groups", ""); wp_update_post(array("ID" => $id, 'post_status' => 'draft')); } } if ($del_post) { wp_delete_post($id, true); } $countSites = 0; foreach ($dbwebsites as $website) { if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) { $countSites++; } } if (!empty($countSites)) { $seconds = time() - $startTime; MainWPTwitter::updateTwitterInfo('new_page', $countSites, $seconds, 1, $startTime, 1); } if (MainWPTwitter::enabledTwitterMessages()) { $twitters = MainWPTwitter::getTwitterNotice('new_page'); if (is_array($twitters)) { foreach ($twitters as $timeid => $twit_mess) { if (!empty($twit_mess)) { $sendText = MainWPTwitter::getTwitToSend('new_page', $timeid); ?> <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="new_page" twit-id="<?php echo $timeid; ?> "><?php echo $twit_mess; ?> </span> <?php MainWPTwitter::genTwitterButton($sendText); ?> <span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php _e('Dismiss', 'mainwp'); ?> </a></span></div> <?php } } } } } ?> <div id="message" class="updated"> <?php foreach ($dbwebsites as $website) { ?> <p><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a> : <?php echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? 'New page created. ' . "<a href=\"" . $output->link[$website->id] . "\" target=\"_blank\">View Page</a>" : 'ERROR: ' . $output->errors[$website->id]; ?> </p> <?php } ?> </div> <?php } else { ?> <div class="error below-h2"> <p><strong>ERROR</strong>: <?php _e('An undefined error occured.', 'mainwp'); ?> </p> </div> <?php } } // no skip posting ?> <br/> <a href="<?php echo get_admin_url(); ?> admin.php?page=PageBulkAdd" class="add-new-h2" target="_top"><?php _e('Add New', 'mainwp'); ?> </a> <a href="<?php echo get_admin_url(); ?> admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php _e('Return to Dashboard', 'mainwp'); ?> </a> </div> <?php }
function mainwp_twitter_dashboard_action() { $success = false; if (isset($_POST['actionName']) && isset($_POST['countSites']) && !empty($_POST['countSites'])) { $success = MainWPTwitter::updateTwitterInfo($_POST['actionName'], $_POST['countSites'], (int) $_POST['countSeconds'], isset($_POST['countRealItems']) ? $_POST['countRealItems'] : 0, time(), isset($_POST['countItems']) ? $_POST['countItems'] : 0); } if (isset($_POST['showNotice']) && !empty($_POST['showNotice'])) { if (MainWPTwitter::enabledTwitterMessages()) { $twitters = MainWPTwitter::getTwitterNotice($_POST['actionName']); $html = ""; if (is_array($twitters)) { foreach ($twitters as $timeid => $twit_mess) { if (!empty($twit_mess)) { $sendText = MainWPTwitter::getTwitToSend($_POST['actionName'], $timeid); $html .= '<div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="' . $_POST['actionName'] . '" twit-id="' . $timeid . '">' . $twit_mess . '</span> ' . MainWPTwitter::genTwitterButton($sendText, false) . '<span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i>' . __('Dismiss', 'mainwp') . '</a></span></div>'; } } } die($html); } } else { if ($success) { die('ok'); } } die(''); }
public static function doPost() { $errors = array(); $errorFields = array(); if (isset($_POST['select_by'])) { $selected_sites = array(); if (isset($_POST['selected_sites']) && is_array($_POST['selected_sites'])) { foreach ($_POST['selected_sites'] as $selected) { $selected_sites[] = $selected; } } $selected_groups = array(); if (isset($_POST['selected_groups']) && is_array($_POST['selected_groups'])) { foreach ($_POST['selected_groups'] as $selected) { $selected_groups[] = $selected; } } if ($_POST['select_by'] == 'group' && count($selected_groups) == 0 || $_POST['select_by'] == 'site' && count($selected_sites) == 0) { $errors[] = 'Please select the sites or groups you want to add the new user to.'; } } else { $errors[] = 'Please select whether you want to add the user to specific sites or groups.'; } if (!isset($_POST['user_login']) || $_POST['user_login'] == '') { $errorFields[] = 'user_login'; } if (!isset($_POST['email']) || $_POST['email'] == '') { $errorFields[] = 'email'; } if (!isset($_POST['pass1']) || $_POST['pass1'] == '' || !isset($_POST['pass2']) || $_POST['pass2'] == '') { $errorFields[] = 'pass1'; } else { if ($_POST['pass1'] != $_POST['pass2']) { $errorFields[] = 'pass2'; } } $allowed_roles = array('subscriber', 'administrator', 'editor', 'author', 'contributor'); if (!isset($_POST['role']) || !in_array($_POST['role'], $allowed_roles)) { $errorFields[] = 'role'; } if (count($errors) == 0 && count($errorFields) == 0) { $user_to_add = array('user_pass' => $_POST['pass1'], 'user_login' => $_POST['user_login'], 'user_url' => $_POST['url'], 'user_email' => $_POST['email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'role' => $_POST['role']); $dbwebsites = array(); if ($_POST['select_by'] == 'site') { //Get all selected websites foreach ($selected_sites as $k) { if (MainWPUtility::ctype_digit($k)) { $website = MainWPDB::Instance()->getWebsiteById($k); $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } } } else { //Get all websites from the selected groups foreach ($selected_groups as $k) { if (MainWPUtility::ctype_digit($k)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } @MainWPDB::free_result($websites); } } } $startTime = time(); if (count($dbwebsites) > 0) { $post_data = array('new_user' => base64_encode(serialize($user_to_add)), 'send_password' => isset($_POST['send_password']) ? $_POST['send_password'] : ''); $output = new stdClass(); $output->ok = array(); $output->errors = array(); MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newuser', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output); } $countSites = 0; foreach ($dbwebsites as $website) { if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) { $countSites++; } } if (!empty($countSites)) { $seconds = time() - $startTime; MainWPTwitter::updateTwitterInfo('create_new_user', $countSites, $seconds, 1, $startTime); } if (MainWPTwitter::enabledTwitterMessages()) { $twitters = MainWPTwitter::getTwitterNotice('create_new_user'); if (is_array($twitters)) { foreach ($twitters as $timeid => $twit_mess) { if (!empty($twit_mess)) { $sendText = MainWPTwitter::getTwitToSend('create_new_user', $timeid); ?> <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="create_new_user" twit-id="<?php echo $timeid; ?> "><?php echo $twit_mess; ?> </span> <?php MainWPTwitter::genTwitterButton($sendText); ?> <span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php _e('Dismiss', 'mainwp'); ?> </a></span></div> <?php } } } } ?> <div id="message" class="updated"> <?php foreach ($dbwebsites as $website) { ?> <p><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a> : <?php echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? 'New user created.' : 'ERROR: ' . $output->errors[$website->id]; ?> </p> <?php } ?> </div> <br/> <a href="<?php echo get_admin_url(); ?> admin.php?page=UserBulkAdd" class="add-new-h2" target="_top"><?php _e('Add New', 'mainwp'); ?> </a> <a href="<?php echo get_admin_url(); ?> admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php _e('Return to Dashboard', 'mainwp'); ?> </a> <?php } else { echo 'ERROR ' . json_encode(array($errorFields, $errors)); } }
function handleSettingsPost() { if (isset($_GET['page'])) { if ($_GET['page'] == 'DashboardOptions') { if (isset($_POST['submit'])) { MainWPUtility::update_option('mainwp_use_favicon', !isset($_POST['mainwp_use_favicon']) ? 0 : 1); MainWPUtility::update_option('mainwp_hide_footer', !isset($_POST['mainwp_hide_footer']) ? 0 : 1); MainWPUtility::update_option('mainwp_hide_tips', !isset($_POST['mainwp_hide_tips']) ? 0 : 1); $enabled_twit = !isset($_POST['mainwp_hide_twitters_message']) ? 0 : 1; MainWPUtility::update_option('mainwp_hide_twitters_message', $enabled_twit); if (!$enabled_twit) { MainWPTwitter::clearAllTwitterMessages(); } } } else { if ($_GET['page'] == "Settings") { if (isset($_POST['submit'])) { if (isset($_POST['mainwp_primaryBackup'])) { MainWPUtility::update_option('mainwp_primaryBackup', $_POST['mainwp_primaryBackup']); } } } } } if (isset($_POST['select_mainwp_options_siteview'])) { $userExtension = MainWPDB::Instance()->getUserExtension(); $userExtension->site_view = empty($_POST['select_mainwp_options_siteview']) ? 0 : 1; MainWPDB::Instance()->updateUserExtension($userExtension); } }
function handleSettingsPost() { if (isset($_GET['page'])) { if ($_GET['page'] == 'DashboardOptions') { if (isset($_POST['submit'])) { MainWPUtility::update_option('mainwp_use_favicon', !isset($_POST['mainwp_use_favicon']) ? 0 : 1); MainWPUtility::update_option('mainwp_hide_footer', !isset($_POST['mainwp_hide_footer']) ? 0 : 1); MainWPUtility::update_option('mainwp_hide_tips', !isset($_POST['mainwp_hide_tips']) ? 0 : 1); $enabled_twit = !isset($_POST['mainwp_hide_twitters_message']) ? 0 : 1; MainWPUtility::update_option('mainwp_hide_twitters_message', $enabled_twit); if (!$enabled_twit) { MainWPTwitter::clearAllTwitterMessages(); } } } else { if ($_GET['page'] == "Settings") { if (isset($_POST['submit'])) { if (isset($_POST['mainwp_primaryBackup'])) { MainWPUtility::update_option('mainwp_primaryBackup', $_POST['mainwp_primaryBackup']); } } } } } }
public static function renderDashboardBody($websites, $pDashboard, $pScreenLayout) { $opts = get_option("mainwp_opts_showhide_sections", false); $hide_shortcuts = is_array($opts) && isset($opts['welcome_shortcuts']) && $opts['welcome_shortcuts'] == 'hide' ? true : false; ?> <form action="admin-post.php" method="post"> <?php wp_nonce_field('mainwp_tab-general'); ?> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> <input type="hidden" name="action" value="save_howto_testPages_general"/> <div id="mainwp-welocme-bar" class="welcome-panel" style="padding-left: 2em;"> <table id="mainwp-refresh-bar" width="100%"> <tbody><tr><td> <div id="mainwp-welocme-bar-top"> <span style="float:right;"> <a style="font-size: 18px;" class="button-hero button mainwp-upgrade-button" id="dashboard_refresh" title="<?php echo MainWPRightNow::renderLastUpdate(); ?> "><?php _e('<i class="fa fa-refresh"></i> Sync Data', 'mainwp'); ?> </a> <a style="font-size: 18px;" class="button-hero button-primary button" target="_blank" href="https://extensions.mainwp.com"><?php _e('<i class="fa fa-cart-plus"></i> Get New Extensions', 'mainwp'); ?> </a> </span> <?php $current_wp_id = MainWPUtility::get_current_wpid(); $website = null; if (!empty($current_wp_id)) { $website = $websites[0]; } $imgfavi = ""; if ($website !== null) { if (get_option('mainwp_use_favicon', 1) == 1) { $favi = MainWPDB::Instance()->getWebsiteOption($website, 'favi_icon', ""); $favi_url = MainWPUtility::get_favico_url($favi, $website); $imgfavi = '<img src="' . $favi_url . '" width="16" height="16" style="vertical-align:middle;"/> '; } } if (time() - ($website == null ? MainWPDB::Instance()->getFirstSyncedSite() : $website->dtsSync) > 60 * 60 * 24) { ?> <h3><i class="fa fa-flag"></i> <?php _e('Your MainWP Dashboard has not been synced for 24 hours!', 'mainwp'); ?> </h3> <p class="about-description"><?php _e('Click the Sync Data button to get the latest data from child sites.', 'mainwp'); ?> </p> <?php } else { ?> <h3><?php echo $website == null ? __('Welcome to Your MainWP Dashboard!', 'mainwp') : sprintf(__('Welcome to %s Dashboard!', 'mainwp'), stripslashes($website->name)); ?> </h3> <p class="about-description"><?php echo $website == null ? __('Manage your WordPress sites with ease.', 'mainwp') : sprintf(__('This information is only for %s%s', 'mainwp'), $imgfavi, MainWPUtility::getNiceURL($website->url, true)); ?> </p> <?php } ?> </div> <br/> <span style="float: right; margin-right: 1em;"><a id="mainwp-link-showhide-welcome-shortcuts" status="<?php echo $hide_shortcuts ? "hide" : "show"; ?> " href="#"><?php echo $hide_shortcuts ? __('Show Shortcuts', 'mainwp') : __('Hide Shortcuts', 'mainwp'); ?> </a></span> <div id="mainwp-welcome-bar-shotcuts" style="clear: both;<?php echo $hide_shortcuts ? "display: none;" : ""; ?> " > <div class="welcome-panel-column"> <h4><?php _e('Get Started', 'mainwp'); ?> </h4> <ul> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=managesites&do=new"><i class="fa fa-globe"></i> <?php _e('Add New Site', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=ManageGroups"><i class="fa fa-globe"></i> <?php _e('Create Child Site Groups', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=ManageBackupsAddNew"><i class="fa fa-hdd-o"></i> <?php _e('Schedule Backups', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=Settings"><i class="fa fa-cogs"></i> <?php _e('Check MainWP Settings', 'mainwp'); ?> </a></li> </ul> </div> <div class="welcome-panel-column"> <h4><?php _e('Next Steps', 'mainwp'); ?> </h4> <ul> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=PostBulkAdd"><i class="fa fa-file-text"></i> <?php _e('Add Post to Child Site(s)', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=PageBulkAdd"><i class="fa fa-file"></i> <?php _e('Add Page to Child Site(s)', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=PluginsInstall"><i class="fa fa-plug"></i> <?php _e('Add Plugin to Child Site(s)', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=ThemesInstall"><i class="fa fa-paint-brush"></i> <?php _e('Add Theme to Child Site(s)', 'mainwp'); ?> </a></li> </ul> </div> <div class="welcome-panel-column welcome-panel-last"> <h4><?php _e('More Actions', 'mainwp'); ?> </h4> <ul> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=managesites&do=test"><i class="fa fa-globe"></i> <?php _e('Test Connection', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=Extensions"><i class="fa fa-plug"></i> <?php _e('Manage Extensions', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=ServerInformation"><i class="fa fa-server"></i> <?php _e('Check MainWP Requirements', 'mainwp'); ?> </a></li> <li><a href="<?php echo get_admin_url(); ?> admin.php?page=DashboardOptions"><i class="fa fa-cogs"></i> <?php _e('Set Your Preferences', 'mainwp'); ?> </a></li> </ul> </div> </div> <div id="dashboard_refresh_statusextra" style="display: none"> <i class="fa fa-spinner fa-pulse"></i> </div> </div> <div id="mainwp_dashboard_refresh_status"></div> </td></tr></tbody> </table> </div> <div id="mainwp_main_errors" class="mainwp_error"></div> </form> <?php if (empty($current_wp_id) && MainWPTwitter::enabledTwitterMessages()) { $filter = array('upgrade_everything', 'upgrade_all_wp_core', 'upgrade_all_plugins', 'upgrade_all_themes'); foreach ($filter as $what) { $twitters = MainWPTwitter::getTwitterNotice($what); if (is_array($twitters)) { foreach ($twitters as $timeid => $twit_mess) { if (!empty($twit_mess)) { $sendText = MainWPTwitter::getTwitToSend($what, $timeid); ?> <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="<?php echo $what; ?> " twit-id="<?php echo $timeid; ?> "><?php echo $twit_mess; ?> </span> <?php MainWPTwitter::genTwitterButton($sendText); ?> <span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php _e('Dismiss', 'mainwp'); ?> </a></span></div> <?php } } } } ?> <?php } ?> <div id="dashboard-widgets-wrap"> <?php require_once ABSPATH . 'wp-admin/includes/dashboard.php'; wp_dashboard(); ?> <div class="clear"></div> </div><!-- dashboard-widgets-wrap --> <?php }