<?php

require_once __DIR__ . '/wp-load.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-orphanage-db-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-image-db-utils.php';
require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php';
require_once ABSPATH . WPINC . '/lib/utils/class-template-utils.php';
if (!is_user_logged_in()) {
    wp_redirect(home_url());
    exit;
}
$orphanageId = RequestHelper::getParameter("orphanage_id");
$orphanage = null;
if ($orphanageId) {
    $orphanage = OrphanageDBUtils::getOrphanageById($orphanageId);
}
$data = ["orphanage" => $orphanage];
TemplateUtils::includeTemplate(get_template_directory() . '/page-templates/orphanage-form.php', $data);
<?php

require_once __DIR__ . '/wp-load.php';
require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php';
require_once ABSPATH . WPINC . '/lib/validator/class-orphanage-form-validator.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-orphanage-db-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-needy-item-settings-db-utils.php';
if (!is_user_logged_in()) {
    wp_redirect(home_url());
    exit;
}
$orphanageInfo = RequestHelper::getOrphanageInfoFromRequest();
if (OrphanageFormValidator::validateAddOrphanageParameters($orphanageInfo)) {
    $image = ImageUtils::createImageFromRequestParameters($orphanageInfo);
    if ($image) {
        $orphanageId = OrphanageDBUtils::createOrphanage($orphanageInfo, $image->image_id);
        NeedyItemSettingsDBUtils::updateOrphanageSettings($orphanageId, $orphanageInfo);
    }
}
wp_redirect(home_url());
exit;
 static function deleteOrphanageById($orphanageId)
 {
     $orphanage = OrphanageDBUtils::getOrphanageById($orphanageId);
     ImageUtils::deleteImageById($orphanage->image_id);
     OrphanageDBUtils::deleteOrphanageById($orphanageId);
 }
<?php

require_once __DIR__ . '/wp-load.php';
require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php';
require_once ABSPATH . WPINC . '/lib/validator/class-orphanage-form-validator.php';
require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-orphanage-db-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-needy-item-settings-db-utils.php';
if (!is_user_logged_in()) {
    wp_redirect(home_url());
    exit;
}
$orphanageInfo = RequestHelper::getOrphanageInfoFromRequest();
if (OrphanageFormValidator::validateEditOrphanageParameters($orphanageInfo)) {
    $orphanage = OrphanageDBUtils::getOrphanageById($orphanageInfo[Orphanage::ID_FIELD]);
    $imageId = $orphanage->image_id;
    if ($orphanage && OrphanageFormValidator::validateOrphanageAvatar($orphanageInfo)) {
        $image = ImageUtils::createImageFromRequestParameters($orphanageInfo);
        if ($image) {
            ImageUtils::deleteImageById($orphanage->image_id);
            $imageId = $image->image_id;
        }
    }
    OrphanageDBUtils::updateOrphanageById($orphanageInfo, $imageId, $orphanage->orphanage_id);
    NeedyItemSettingsDBUtils::updateOrphanageSettings($orphanage->orphanage_id, $orphanageInfo);
}
wp_redirect(home_url());
exit;
示例#5
0
require_once ABSPATH . WPINC . '/lib/utils/class-needy-item-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-child-db-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-orphanage-db-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-image-db-utils.php';
require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php';
$needyId = RequestHelper::getParameter("needy_id");
$needyType = RequestHelper::getParameter("needy_type");
$child = null;
$editPageController = null;
$donateHiddenId = null;
if ($needyId && $needyType == NeedyType::CHILD) {
    $child = ChildDBUtils::getChildById($needyId);
    $editPageController = '/edit-child-page-controller.php?child_id=' . $needyId;
    $donateHiddenId = "child_id";
} elseif ($needyId && $needyType == NeedyType::ORPHANAGE) {
    $child = OrphanageDBUtils::getOrphanageById($needyId);
    $editPageController = '/edit-orphanage-page-controller.php?orphanage_id=' . $needyId;
    $donateHiddenId = "orphanage_id";
}
get_header();
?>

<?php 
if ($child) {
    ?>
    <div class="child-info <?php 
    if (NeedyItemUtils::isItemSupportStatus($child)) {
        echo NeedyStatus::getNeedyClassByStatuses($child->status);
    }
    ?>
">