Example #1
0
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 */

if(isset($_GET['remove']) && !empty($_GET['remove'])) : ?>

	<span class="ceos-header-msg error">
		<form class="inner" method="POST" action="<?= \CEOS\Slider\PLUGIN_PATH_URL ?>services/remove_slider.php">
			<input type="hidden" name="nonce" value="<?= wp_create_nonce(\CEOS\Slider\PLUGIN_PREFIX . '_remove_' . $_GET['remove'] . get_current_user_id()) ?>">
			<input type="hidden" name="id" value="<?= $_GET['remove'] ?>">

			<span class="icon"></span>
			<span class="text"><?= __('Are you sure you want to the remove "<b>' . \CEOS\Slider\Slider::getSliderTitle($_GET['remove']) . '</b>"?') ?></span>
			<span class="controls">
				<input type="submit" class="button button-secondary" value="<?= __('Yes') ?>">
				<a id="msg-cancel" href="javascript:void(0)" class="button button-primary"><?= __('No') ?></a>
			</span>
		</form>

		<script type="text/javascript">
			document.getElementById('msg-cancel')
				.addEventListener('click', function () {
				document.getElementsByClassName('ceos-header-msg error')[0].remove();
			})
		</script>
	</span>

<? endif;
Example #2
0
function menuPage()
{
    include 'header.php';
    $sliders = \CEOS\Slider\Slider::getSliders();
    ?>
	
	<div class="ceos-slider admin-page menu-page">

		<div class="ceos-table">
			<div class="ceos-table-header">
				<span class="ceos-table-hd"><?php 
    echo __('Slider');
    ?>
</span>
				<span class="ceos-table-hd"><?php 
    echo __('ID');
    ?>
</span>
				<span class="ceos-table-hd"><?php 
    echo __('Items');
    ?>
</span>
			</div>
			<?php 
    if ($sliders && sizeof($sliders) > 0) {
        ?>
			
				<?php 
        foreach ($sliders as $slider) {
            ?>
					<div class="ceos-table-row">
						<span class="ceos-table-td title">
							<b><a href="<?php 
            echo admin_url('admin.php?page=' . \CEOS\Slider\PLUGIN_PREFIX . 'create&edit=' . $slider->slid_id);
            ?>
"><?php 
            echo $slider->slid_title;
            ?>
</a></b>
							<div class="actions">
								<a href="<?php 
            echo admin_url('admin.php?page=' . \CEOS\Slider\PLUGIN_PREFIX . 'create&edit=' . $slider->slid_id);
            ?>
" class="edit"><?php 
            echo __('Edit');
            ?>
</a>
								<span class="sep">|</span>
								<a href="<?php 
            echo admin_url('admin.php?page=' . \CEOS\Slider\PLUGIN_PREFIX . 'menu_page&remove=' . $slider->slid_id);
            ?>
" class="trash"><?php 
            echo __('Remove');
            ?>
</a>
							</div>
						</span>
						<span class="ceos-table-td id"><?php 
            echo $slider->slid_id;
            ?>
</span>
						<span class="ceos-table-td count"><?php 
            echo $slider->count;
            ?>
</span>
					</div>
				<?php 
        }
        ?>

			<?php 
    } else {
        ?>
				
				<div class="ceos-empty">
					<div><?php 
        echo __('There are no sliders available. <a href="' . admin_url('admin.php?page=' . \CEOS\Slider\PLUGIN_PREFIX . 'create') . '">Click here</a> to create a new one.');
        ?>
</div>
				</div>
			
			<?php 
    }
    ?>
		</div>

	</div>

	<?php 
    include 'footer.php';
}
/**
 * This scripts is ment for pushing a slider into the database. So it only
 * accept POST requests.
 */

if($_SERVER['REQUEST_METHOD'] != 'POST') {
	$error = 'status=invalid_method';
	require('footer.php');
	exit;
}

/**
 * Nonce verification
 */

$nonceAction = \CEOS\Slider\PLUGIN_PREFIX . '_remove_' . $_POST['id'] . get_current_user_id();

if(!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], $nonceAction)) {
	$error = 'status=invalid_verification';
	require('footer.php');
	exit;
}

if(!isset($_POST['id']) 
	|| !\CEOS\Slider\Slider::removeFromDatabase($_POST['id'])) {
	$error = 'status=remove_error';
	require('footer.php');
	exit;
}

require('footer.php');