/**
  * Remove submission
  *
  * @access public
  * @return void
  */
 public static function submission_remove($atts)
 {
     if (!is_user_logged_in() || empty($_GET['id'])) {
         echo Realia_Template_Loader::load('misc/not-allowed');
         return;
     }
     $is_allowed = Realia_Utilities::is_allowed_to_remove(get_current_user_id(), $_GET['id']);
     if (!$is_allowed) {
         echo Realia_Template_Loader::load('misc/not-allowed');
         return;
     }
     if (wp_delete_post($_GET['id'])) {
         $_SESSION['messages'][] = array('success', __('Item has been successfully removed.', 'realia'));
     } else {
         $_SESSION['messages'][] = array('danger', __('An error occured when removing an item.', 'realia'));
     }
 }
예제 #2
0
<?php

if (method_exists('Realia_Utilities', 'protect')) {
    Realia_Utilities::protect();
}
?>

<?php 
/**
 * Template Name: Favorites
 */
?>

<?php 
get_header();
?>

<div class="row">
	<div class="content <?php 
if (is_active_sidebar('sidebar-1')) {
    ?>
col-sm-8 col-md-9<?php 
} else {
    ?>
col-sm-12<?php 
}
?>
">
        <?php 
include 'templates/authenticated-tabs.php';
?>
예제 #3
0
 /**
  * Loads image from external source
  *
  * @access public
  * @param $filename
  * @param $post_id
  * @return int
  */
 public static function import_attachment($filename, $post_id)
 {
     require_once ABSPATH . 'wp-admin/includes/image.php';
     require_once ABSPATH . 'wp-admin/includes/media.php';
     require_once ABSPATH . 'wp-admin/includes/file.php';
     $is_external = false;
     // If the image path is starting with http we are gonna to download it
     if (substr($filename, 0, 4) === 'http') {
         $is_external = true;
         $image_id = Realia_Utilities::media_sideload_image($filename, $post_id);
         $image = wp_get_attachment_image_src($image_id, 'full');
     }
     $filetype = wp_check_filetype(basename($filename), null);
     $wp_upload_dir = wp_upload_dir();
     $args = array('guid' => $wp_upload_dir['url'] . '/' . basename($filename), 'post_mime_type' => $filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($filename)), 'post_content' => '', 'post_status' => 'inherit');
     if ($is_external) {
         $args['guid'] = $image[0];
         $attachment_id = wp_insert_attachment($args, get_attached_file($image_id), $post_id);
         $attachment_data = wp_generate_attachment_metadata($attachment_id, get_attached_file($image_id));
     } else {
         $attachment_id = wp_insert_attachment($args, $filename, $post_id);
         $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
     }
     wp_update_attachment_metadata($attachment_id, $attachment_data);
     return $attachment_id;
 }
예제 #4
0
        the_ID();
        ?>
)" 
                   data-ng-show='!is_included(<?php 
        the_ID();
        ?>
)'>
          		<i class="fa fa-heart-o"></i>
          	</a>
        </span>
    <?php 
    } else {
        ?>

        <?php 
        $link = Realia_Utilities::get_link_for_login();
        ?>

        <span>
        <?php 
        if ($link) {
            ?>

            <a href="<?php 
            echo esc_attr($link);
            ?>
" class="favorites-action action-link" title="<?php 
            echo __('Agregar a los favoritos', 'realia');
            ?>
">
                <i class="fa fa-heart-o"></i>
예제 #5
0
<?php

if (!empty($_SESSION['messages']) && is_array($_SESSION['messages'])) {
    ?>
	<?php 
    $_SESSION['messages'] = Realia_Utilities::array_unique_multidimensional($_SESSION['messages']);
    ?>

	<div class="alerts">
		<?php 
    foreach ($_SESSION['messages'] as $message) {
        ?>
			<div class="alert alert-<?php 
        echo esc_attr($message[0]);
        ?>
">
				<?php 
        echo wp_kses($message[1], wp_kses_allowed_html('post'));
        ?>
			</div><!-- /.alert -->
		<?php 
    }
    ?>
	</div><!-- /.alerts -->
	
	<?php 
    unset($_SESSION['messages']);
}