function WP_ayvpp_import_actions() { global $getWP, $tern_wp_youtube_options, $tern_wp_youtube_vids, $getFILE; $o = $getWP->getOption('tern_wp_youtube', $tern_wp_youtube_options); if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'tern_wp_youtube_nonce') or !current_user_can('manage_options')) { return; } switch ($_REQUEST['action']) { case 'ayvpp_is_importing': if ($o['is_importing'] and $o['is_importing'] !== false) { die('1'); } die(0); case 'ayvpp_import': WP_ayvpp_add_posts(1, '*'); $o['is_importing'] = false; $o = $getWP->getOption('tern_wp_youtube', $o, true); die('Your import is complete!'); case 'ayvpp_status': die($getFILE->contents(WP_CONTENT_DIR . '/cache/ayvpp.txt')); case 'ayvpp_file': $f = $getFILE->createFile('ayvpp.txt', '', WP_CONTENT_DIR . '/cache'); if ($f === true) { die('true'); } else { die('false'); } default: break; } }
function WP_ayvpp_channel_actions() { global $getWP, $tern_wp_youtube_options, $wpdb, $tern_wp_youtube_post_defaults; $o = $getWP->getOption('tern_wp_youtube', $tern_wp_youtube_options); if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'tern_wp_youtube_nonce') or !current_user_can('manage_options')) { return; } $action = empty($_REQUEST['action']) ? $_REQUEST['action2'] : $_REQUEST['action']; switch ($action) { case 'delete': foreach ($_REQUEST['items'] as $v) { unset($o['channels'][$v]); } $o = $getWP->getOption('tern_wp_youtube', $o, true); $getWP->addAlert(__('You have successfully deleted your channel/playlist.', 'ayvpp')); break; case 'add': if (!empty($_REQUEST['item']) or $_REQUEST['item'] === 0 or $_REQUEST['item'] === '0') { $i = $_REQUEST['item']; } else { foreach ($o['channels'] as $v) { if ($v['channel'] == $_POST['channel']) { $getWP->addError('You have already added the channel: "' . $_POST['channel'] . '".'); break 2; } } $i = array_keys($o['channels']); $i = $i[count($i) - 1] + 1; } if (empty($_POST['name']) or empty($_POST['channel']) or empty($_POST['type']) or empty($_POST['categories']) or empty($_POST['author'])) { $getWP->addError('Please fill out all the fields for a channel/playlist.'); return; } $o['channels'][$i] = array('id' => intval($i), 'name' => $_POST['name'], 'channel' => $_POST['channel'], 'type' => $_POST['type'], 'categories' => $_POST['categories'], 'author' => $_POST['author']); $o = $getWP->getOption('tern_wp_youtube', $o, true); WP_ayvpp_add_posts(1, 20, true); break; default: break; } }