changed all role occurences by a const
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,381 +0,0 @@
|
|||||||
|
|
||||||
console.log("---------------inside image_editor.js--------------");
|
|
||||||
const edit_image_button = document.getElementById('edit_image');
|
|
||||||
const image_id_field = document.getElementById('image_id');
|
|
||||||
const media_editor = document.getElementById('media_editor');
|
|
||||||
|
|
||||||
edit_image_button.addEventListener('click', () => {
|
|
||||||
const image_id = image_id_field.value;
|
|
||||||
|
|
||||||
//PLGNTLS_ajax("postid", image_id, 'image-editor')
|
|
||||||
const data_obj = {
|
|
||||||
'postid': image_id,
|
|
||||||
};
|
|
||||||
PLGNTLS_ajax(data_obj, 'image_editor_PLGNTLS')
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((data) => {
|
|
||||||
console.log("data: ");
|
|
||||||
console.log(data);
|
|
||||||
media_editor.innerHTML = data.data.html;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log("error: ");
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
open: function (e, t, i) { // t: nonce
|
|
||||||
this._view = i; // div: #media-editor-114
|
|
||||||
var a = c('#image-editor-' + e), // e: image id
|
|
||||||
o = c('#media-head-' + e),
|
|
||||||
r = c('#imgedit-open-btn-' + e),
|
|
||||||
s = r.siblings('.spinner');
|
|
||||||
if (!r.hasClass('button-activated')) return s.addClass('is-active'),
|
|
||||||
c.ajax({
|
|
||||||
url: ajaxurl,
|
|
||||||
type: 'post',
|
|
||||||
data: {
|
|
||||||
action: 'image-editor',
|
|
||||||
_ajax_nonce: t,
|
|
||||||
postid: e,
|
|
||||||
do : 'open'},
|
|
||||||
beforeSend: function () {
|
|
||||||
r.addClass('button-activated')
|
|
||||||
}
|
|
||||||
}).done(
|
|
||||||
function (t) {
|
|
||||||
var i;
|
|
||||||
'-1' === t &&
|
|
||||||
(
|
|
||||||
i = n('Could not load the preview image.'),
|
|
||||||
a.html(
|
|
||||||
'<div class="notice notice-error" tabindex="-1" role="alert"><p>' + i + '</p></div>'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
t.data &&
|
|
||||||
t.data.html &&
|
|
||||||
a.html(t.data.html),
|
|
||||||
o.fadeOut(
|
|
||||||
'fast',
|
|
||||||
function () {
|
|
||||||
a.fadeIn(
|
|
||||||
'fast',
|
|
||||||
function () {
|
|
||||||
i &&
|
|
||||||
c(document).trigger('image-editor-ui-ready')
|
|
||||||
}
|
|
||||||
),
|
|
||||||
r.removeClass('button-activated'),
|
|
||||||
s.removeClass('is-active')
|
|
||||||
}
|
|
||||||
),
|
|
||||||
l.init(e)
|
|
||||||
}
|
|
||||||
) },
|
|
||||||
imgLoaded: function (t) {
|
|
||||||
var i = c('#image-preview-' + t),
|
|
||||||
e = c('#imgedit-crop-' + t);
|
|
||||||
void 0 === this.hold.sizer &&
|
|
||||||
this.init(t),
|
|
||||||
this.initCrop(t, i, e),
|
|
||||||
this.setCropSelection(
|
|
||||||
t,
|
|
||||||
{
|
|
||||||
x1: 0,
|
|
||||||
y1: 0,
|
|
||||||
x2: 0,
|
|
||||||
y2: 0,
|
|
||||||
width: i.innerWidth(),
|
|
||||||
height: i.innerHeight()
|
|
||||||
}
|
|
||||||
),
|
|
||||||
this.toggleEditor(t, 0, !0)
|
|
||||||
},
|
|
||||||
focusManager: function () {
|
|
||||||
setTimeout(
|
|
||||||
function () {
|
|
||||||
var t = c('.notice[role="alert"]');
|
|
||||||
(t = t.length ? t : c('.imgedit-wrap').find(':tabbable:first')).attr('tabindex', '-1').trigger('focus')
|
|
||||||
},
|
|
||||||
100
|
|
||||||
)
|
|
||||||
},
|
|
||||||
initCrop: function (a, t, i) {
|
|
||||||
var o = this,
|
|
||||||
r = c('#imgedit-sel-width-' + a),
|
|
||||||
s = c('#imgedit-sel-height-' + a),
|
|
||||||
n = c('#imgedit-start-x-' + a),
|
|
||||||
d = c('#imgedit-start-y-' + a),
|
|
||||||
t = c(t);
|
|
||||||
t.data('imgAreaSelect') ||
|
|
||||||
(
|
|
||||||
o.iasapi = t.imgAreaSelect({
|
|
||||||
parent: i,
|
|
||||||
instance: !0,
|
|
||||||
handles: !0,
|
|
||||||
keys: !0,
|
|
||||||
minWidth: 3,
|
|
||||||
minHeight: 3,
|
|
||||||
onInit: function (t) {
|
|
||||||
c(t).next().css('position', 'absolute').nextAll('.imgareaselect-outer').css('position', 'absolute'),
|
|
||||||
i.children().on(
|
|
||||||
'mousedown, touchstart',
|
|
||||||
function (t) {
|
|
||||||
var i,
|
|
||||||
e = !1;
|
|
||||||
t.shiftKey &&
|
|
||||||
(
|
|
||||||
t = o.iasapi.getSelection(),
|
|
||||||
i = o.getSelRatio(a),
|
|
||||||
e = t &&
|
|
||||||
t.width &&
|
|
||||||
t.height ? t.width + ':' + t.height : i
|
|
||||||
),
|
|
||||||
o.iasapi.setOptions({
|
|
||||||
aspectRatio: e
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onSelectStart: function () {
|
|
||||||
l.setDisabled(c('#imgedit-crop-sel-' + a), 1),
|
|
||||||
l.setDisabled(c('.imgedit-crop-clear'), 1),
|
|
||||||
l.setDisabled(c('.imgedit-crop-apply'), 1)
|
|
||||||
},
|
|
||||||
onSelectEnd: function (t, i) {
|
|
||||||
l.setCropSelection(a, i),
|
|
||||||
c('#imgedit-crop > *').is(':visible') ||
|
|
||||||
l.toggleControls(c('.imgedit-crop.button'))
|
|
||||||
},
|
|
||||||
onSelectChange: function (t, i) {
|
|
||||||
var e = l.hold.sizer;
|
|
||||||
r.val(l.round(i.width / e)),
|
|
||||||
s.val(l.round(i.height / e)),
|
|
||||||
n.val(l.round(i.x1 / e)),
|
|
||||||
d.val(l.round(i.y1 / e))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
},
|
|
||||||
setCropSelection: function (t, i) {
|
|
||||||
if (!(i = i || 0) || i.width < 3 && i.height < 3) return this.setDisabled(c('.imgedit-crop', '#imgedit-panel-' + t), 1),
|
|
||||||
this.setDisabled(c('#imgedit-crop-sel-' + t), 1),
|
|
||||||
c('#imgedit-sel-width-' + t).val(''),
|
|
||||||
c('#imgedit-sel-height-' + t).val(''),
|
|
||||||
c('#imgedit-start-x-' + t).val('0'),
|
|
||||||
c('#imgedit-start-y-' + t).val('0'),
|
|
||||||
c('#imgedit-selection-' + t).val(''),
|
|
||||||
!1;
|
|
||||||
i = {
|
|
||||||
x: i.x1,
|
|
||||||
y: i.y1,
|
|
||||||
w: i.width,
|
|
||||||
h: i.height
|
|
||||||
},
|
|
||||||
this.setDisabled(c('.imgedit-crop', '#imgedit-panel-' + t), 1),
|
|
||||||
c('#imgedit-selection-' + t).val(JSON.stringify(i))
|
|
||||||
},
|
|
||||||
close: function (t, i) {
|
|
||||||
if ((i = i || !1) && this.notsaved(t)) return !1;
|
|
||||||
this.iasapi = {},
|
|
||||||
this.hold = {},
|
|
||||||
this._view ? this._view.back() : c('#image-editor-' + t).fadeOut(
|
|
||||||
'fast',
|
|
||||||
function () {
|
|
||||||
c('#media-head-' + t).fadeIn(
|
|
||||||
'fast',
|
|
||||||
function () {
|
|
||||||
c('#imgedit-open-btn-' + t).trigger('focus')
|
|
||||||
}
|
|
||||||
),
|
|
||||||
c(this).empty()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
notsaved: function (t) {
|
|
||||||
var i = c('#imgedit-history-' + t).val(),
|
|
||||||
i = '' !== i ? JSON.parse(i) : [];
|
|
||||||
return this.intval(c('#imgedit-undone-' + t).val()) < i.length &&
|
|
||||||
!confirm(c('#imgedit-leaving-' + t).text())
|
|
||||||
},
|
|
||||||
addStep: function (t, i, e) {
|
|
||||||
for (
|
|
||||||
var a = this,
|
|
||||||
o = c('#imgedit-history-' + i),
|
|
||||||
r = '' !== o.val() ? JSON.parse(o.val()) : [],
|
|
||||||
s = c('#imgedit-undone-' + i),
|
|
||||||
n = a.intval(s.val());
|
|
||||||
0 < n;
|
|
||||||
) r.pop(),
|
|
||||||
n--;
|
|
||||||
s.val(0),
|
|
||||||
r.push(t),
|
|
||||||
o.val(JSON.stringify(r)),
|
|
||||||
a.refreshEditor(
|
|
||||||
i,
|
|
||||||
e,
|
|
||||||
function () {
|
|
||||||
a.setDisabled(c('#image-undo-' + i), !0),
|
|
||||||
a.setDisabled(c('#image-redo-' + i), !1)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
rotate: function (t, i, e, a) {
|
|
||||||
if (c(a).hasClass('disabled')) return !1;
|
|
||||||
this.closePopup(a),
|
|
||||||
this.addStep({
|
|
||||||
r: {
|
|
||||||
r: t,
|
|
||||||
fw: this.hold.h,
|
|
||||||
fh: this.hold.w
|
|
||||||
}
|
|
||||||
}, i, e)
|
|
||||||
},
|
|
||||||
flip: function (t, i, e, a) {
|
|
||||||
if (c(a).hasClass('disabled')) return !1;
|
|
||||||
this.closePopup(a),
|
|
||||||
this.addStep({
|
|
||||||
f: {
|
|
||||||
f: t,
|
|
||||||
fw: this.hold.w,
|
|
||||||
fh: this.hold.h
|
|
||||||
}
|
|
||||||
}, i, e)
|
|
||||||
},
|
|
||||||
crop: function (t, i, e) {
|
|
||||||
var a = c('#imgedit-selection-' + t).val(),
|
|
||||||
o = this.intval(c('#imgedit-sel-width-' + t).val()),
|
|
||||||
r = this.intval(c('#imgedit-sel-height-' + t).val());
|
|
||||||
if (c(e).hasClass('disabled') || '' === a) return !1;
|
|
||||||
0 < (a = JSON.parse(a)).w &&
|
|
||||||
0 < a.h &&
|
|
||||||
0 < o &&
|
|
||||||
0 < r &&
|
|
||||||
(a.fw = o, a.fh = r, this.addStep({
|
|
||||||
c: a
|
|
||||||
}, t, i)),
|
|
||||||
c('#imgedit-sel-width-' + t).val(''),
|
|
||||||
c('#imgedit-sel-height-' + t).val(''),
|
|
||||||
c('#imgedit-start-x-' + t).val('0'),
|
|
||||||
c('#imgedit-start-y-' + t).val('0')
|
|
||||||
},
|
|
||||||
undo: function (i, t) {
|
|
||||||
var e = this,
|
|
||||||
a = c('#image-undo-' + i),
|
|
||||||
o = c('#imgedit-undone-' + i),
|
|
||||||
r = e.intval(o.val()) + 1;
|
|
||||||
a.hasClass('disabled') ||
|
|
||||||
(
|
|
||||||
o.val(r),
|
|
||||||
e.refreshEditor(
|
|
||||||
i,
|
|
||||||
t,
|
|
||||||
function () {
|
|
||||||
var t = c('#imgedit-history-' + i),
|
|
||||||
t = '' !== t.val() ? JSON.parse(t.val()) : [];
|
|
||||||
e.setDisabled(c('#image-redo-' + i), !0),
|
|
||||||
e.setDisabled(a, r < t.length),
|
|
||||||
t.length === r &&
|
|
||||||
c('#image-redo-' + i).trigger('focus')
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
redo: function (t, i) {
|
|
||||||
var e = this,
|
|
||||||
a = c('#image-redo-' + t),
|
|
||||||
o = c('#imgedit-undone-' + t),
|
|
||||||
r = e.intval(o.val()) - 1;
|
|
||||||
a.hasClass('disabled') ||
|
|
||||||
(
|
|
||||||
o.val(r),
|
|
||||||
e.refreshEditor(
|
|
||||||
t,
|
|
||||||
i,
|
|
||||||
function () {
|
|
||||||
e.setDisabled(c('#image-undo-' + t), !0),
|
|
||||||
e.setDisabled(a, 0 < r),
|
|
||||||
0 == r &&
|
|
||||||
c('#image-undo-' + t).trigger('focus')
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
setNumSelection: function (t, i) {
|
|
||||||
var e = c('#imgedit-sel-width-' + t),
|
|
||||||
a = c('#imgedit-sel-height-' + t),
|
|
||||||
o = c('#imgedit-start-x-' + t),
|
|
||||||
r = c('#imgedit-start-y-' + t),
|
|
||||||
o = this.intval(o.val()),
|
|
||||||
r = this.intval(r.val()),
|
|
||||||
s = this.intval(e.val()),
|
|
||||||
n = this.intval(a.val()),
|
|
||||||
d = c('#image-preview-' + t),
|
|
||||||
l = d.height(),
|
|
||||||
d = d.width(),
|
|
||||||
h = this.hold.sizer,
|
|
||||||
g = this.iasapi;
|
|
||||||
if (!1 !== this.validateNumeric(i)) return s < 1 ? (e.val(''), !1) : n < 1 ? (a.val(''), !1) : void (
|
|
||||||
(s && n || o && r) &&
|
|
||||||
(i = g.getSelection()) &&
|
|
||||||
(
|
|
||||||
s = i.x1 + Math.round(s * h),
|
|
||||||
n = i.y1 + Math.round(n * h),
|
|
||||||
o = o === i.x1 ? i.x1 : Math.round(o * h),
|
|
||||||
i = r === i.y1 ? i.y1 : Math.round(r * h),
|
|
||||||
d < s &&
|
|
||||||
(o = 0, s = d, e.val(Math.round(s / h))),
|
|
||||||
l < n &&
|
|
||||||
(i = 0, n = l, a.val(Math.round(n / h))),
|
|
||||||
g.setSelection(o, i, s, n),
|
|
||||||
g.update(),
|
|
||||||
this.setCropSelection(t, g.getSelection())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
round: function (t) {
|
|
||||||
var i;
|
|
||||||
return t = Math.round(t),
|
|
||||||
0.6 < this.hold.sizer ? t : '1' === (i = t.toString().slice( - 1)) ? t - 1 : '9' === i ? t + 1 : t
|
|
||||||
},
|
|
||||||
setRatioSelection: function (t, i, e) {
|
|
||||||
var a = this.intval(c('#imgedit-crop-width-' + t).val()),
|
|
||||||
o = this.intval(c('#imgedit-crop-height-' + t).val()),
|
|
||||||
r = c('#image-preview-' + t).height();
|
|
||||||
!1 === this.validateNumeric(e) ? this.iasapi.setOptions({
|
|
||||||
aspectRatio: null
|
|
||||||
}) : a &&
|
|
||||||
o &&
|
|
||||||
(
|
|
||||||
this.iasapi.setOptions({
|
|
||||||
aspectRatio: a + ':' + o
|
|
||||||
}),
|
|
||||||
e = this.iasapi.getSelection(!0)
|
|
||||||
) &&
|
|
||||||
(
|
|
||||||
r < (a = Math.ceil(e.y1 + (e.x2 - e.x1) / (a / o))) ? (
|
|
||||||
a = r,
|
|
||||||
o = n(
|
|
||||||
'Selected crop ratio exceeds the boundaries of the image. Try a different ratio.'
|
|
||||||
),
|
|
||||||
c('#imgedit-crop-' + t).prepend(
|
|
||||||
'<div class="notice notice-error" tabindex="-1" role="alert"><p>' + o + '</p></div>'
|
|
||||||
),
|
|
||||||
wp.a11y.speak(o, 'assertive'),
|
|
||||||
c(i ? '#imgedit-crop-height-' + t : '#imgedit-crop-width-' + t).val('')
|
|
||||||
) : void 0 !== (r = c('#imgedit-crop-' + t).find('.notice-error')) &&
|
|
||||||
r.remove(),
|
|
||||||
this.iasapi.setSelection(e.x1, e.y1, e.x2, a),
|
|
||||||
this.iasapi.update()
|
|
||||||
)
|
|
||||||
},
|
|
||||||
validateNumeric: function (t) {
|
|
||||||
if (!1 === this.intval(c(t).val())) return c(t).val(''),
|
|
||||||
!1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}(jQuery);
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
@@ -12,21 +12,32 @@ if (!defined('ABSPATH')) {
|
|||||||
|
|
||||||
function restrict_author_page_CIPF() {
|
function restrict_author_page_CIPF() {
|
||||||
PLGNTLS_class::debug_infos();
|
PLGNTLS_class::debug_infos();
|
||||||
|
$role_fipf = PLGNTLS_class::ROLE_FIPF;
|
||||||
|
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||||
|
|
||||||
if (!is_author())
|
if (!is_author())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$can_access = false;
|
$current_user = wp_get_current_user();
|
||||||
if (current_user_can('administrator')) {
|
|
||||||
$can_access = true;
|
|
||||||
}
|
|
||||||
else if (current_user_can('editor')) {
|
|
||||||
$can_access = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($can_access === true)
|
/*
|
||||||
|
* check multiple user roles
|
||||||
|
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
|
||||||
|
* if user->role is found in array of allowed role, no redirection needed
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$allowed_roles = array($role_admin, $role_fipf);
|
||||||
|
if (array_intersect($allowed_roles, $current_user->roles))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get_queried_object_id() would work too
|
||||||
|
* here get_the_author_meta works and is more explicit
|
||||||
|
*
|
||||||
|
$author_id = get_queried_object_id();
|
||||||
|
*/
|
||||||
$author_id = get_the_author_meta( 'ID' );
|
$author_id = get_the_author_meta( 'ID' );
|
||||||
|
|
||||||
$current_user_id = get_current_user_id();
|
$current_user_id = get_current_user_id();
|
||||||
|
|
||||||
if ($current_user_id != $author_id) {
|
if ($current_user_id != $author_id) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function filter_email_fb_CIPF($reply_body, $post_array) {
|
|||||||
return $new_body;
|
return $new_body;
|
||||||
}
|
}
|
||||||
add_filter('df_confirmation_body', 'filter_email_fb_CIPF', 10, 2); // the receive an email
|
add_filter('df_confirmation_body', 'filter_email_fb_CIPF', 10, 2); // the receive an email
|
||||||
add_filter('df_notification_body', 'filter_email_fb_CIPF', 10, 2); // the administrator receive a notification
|
add_filter('df_notification_body', 'filter_email_fb_CIPF', 10, 2); // the admin receive a notification
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ if (!defined('ABSPATH')) {
|
|||||||
*/
|
*/
|
||||||
function hide_admin_bar_CIPF() {
|
function hide_admin_bar_CIPF() {
|
||||||
PLGNTLS_class::debug_infos();
|
PLGNTLS_class::debug_infos();
|
||||||
if (!current_user_can('administrator') && !is_admin()) {
|
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||||
|
|
||||||
|
if (!current_user_can($role_admin) && !is_admin()) {
|
||||||
show_admin_bar(false);
|
show_admin_bar(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* it means someone outside wp is accessing the file, in this case kill it.
|
|
||||||
*/
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
die('You can not access this file!');
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php acf_form_head(); ?>
|
|
||||||
<?php get_header(); ?>
|
|
||||||
|
|
||||||
<div id="primary">
|
|
||||||
<div id="content" role="main">
|
|
||||||
|
|
||||||
<?php /* The loop */ ?>
|
|
||||||
<?php while ( have_posts() ) : the_post(); ?>
|
|
||||||
|
|
||||||
<h1><?php the_title(); ?></h1>
|
|
||||||
|
|
||||||
<?php the_content(); ?>
|
|
||||||
|
|
||||||
<p>My custom field: <?php the_field('my_custom_field'); ?></p>
|
|
||||||
|
|
||||||
<?php acf_form(); ?>
|
|
||||||
|
|
||||||
<?php endwhile; ?>
|
|
||||||
|
|
||||||
</div><!-- #content -->
|
|
||||||
</div><!-- #primary -->
|
|
||||||
|
|
||||||
<?php get_footer(); ?>
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* it means someone outside wp is accessing the file, in this case kill it.
|
|
||||||
*/
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
die('You can not access this file!');
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
function cipfcard_image_editor()
|
|
||||||
{
|
|
||||||
// ob_start();
|
|
||||||
// wp_image_editor('33545');
|
|
||||||
// return ob_get_clean();
|
|
||||||
$cipfcard_image_editor = new PLGNTLS_class();
|
|
||||||
return $cipfcard_image_editor->add_to_front(
|
|
||||||
array(
|
|
||||||
"js/image_editor.js",
|
|
||||||
"html/image_editor.html",
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// if ( ! has_action( "wp_ajax_{$action}" ) ) {
|
|
||||||
// it returns error 400
|
|
||||||
|
|
||||||
}
|
|
||||||
add_shortcode('cipfcard_image_editor', 'cipfcard_image_editor');
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles image editing via AJAX.
|
|
||||||
* from wp-admin/includes/ajax-action.php
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
function wp_ajax_image_editor() {
|
|
||||||
$attachment_id = (int) $_POST['postid'];
|
|
||||||
// $attachment_id = 33555;
|
|
||||||
|
|
||||||
// if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
|
|
||||||
// wp_die( -1 );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// check_ajax_referer( "image_editor-$attachment_id" );
|
|
||||||
// require_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
|
||||||
|
|
||||||
$msg = false;
|
|
||||||
|
|
||||||
switch ( $_POST['do'] ) {
|
|
||||||
case 'save':
|
|
||||||
$msg = wp_save_image( $attachment_id );
|
|
||||||
if ( ! empty( $msg->error ) ) {
|
|
||||||
wp_send_json_error( $msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_send_json_success( $msg );
|
|
||||||
break;
|
|
||||||
case 'scale':
|
|
||||||
$msg = wp_save_image( $attachment_id );
|
|
||||||
break;
|
|
||||||
case 'restore':
|
|
||||||
$msg = wp_restore_image( $attachment_id );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
wp_image_editor( $attachment_id, $msg );
|
|
||||||
$html = ob_get_clean();
|
|
||||||
|
|
||||||
if ( ! empty( $msg->error ) ) {
|
|
||||||
wp_send_json_error(
|
|
||||||
array(
|
|
||||||
'message' => $msg,
|
|
||||||
'html' => $html,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_send_json_success(
|
|
||||||
array(
|
|
||||||
'message' => $msg,
|
|
||||||
'html' => $html,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
add_action( 'wp_ajax_image_editor', 'wp_ajax_image_editor' );
|
|
||||||
*/
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -17,6 +17,8 @@ if (!defined('ABSPATH')) {
|
|||||||
function redirection_page_CIPF(){
|
function redirection_page_CIPF(){
|
||||||
PLGNTLS_class::debug_infos();
|
PLGNTLS_class::debug_infos();
|
||||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||||
|
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||||
|
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
||||||
|
|
||||||
if (!is_page($slug_page_redirection))
|
if (!is_page($slug_page_redirection))
|
||||||
return;
|
return;
|
||||||
@@ -26,11 +28,11 @@ function redirection_page_CIPF(){
|
|||||||
if (!is_user_logged_in()) {
|
if (!is_user_logged_in()) {
|
||||||
wp_redirect($base_url, 301);
|
wp_redirect($base_url, 301);
|
||||||
}
|
}
|
||||||
if (current_user_can('professeur__professeure')) {
|
if (current_user_can($role_prof)) {
|
||||||
$user_page = get_author_posts_url($current_user_id);
|
$user_page = get_author_posts_url($current_user_id);
|
||||||
wp_redirect($user_page, 301);
|
wp_redirect($user_page, 301);
|
||||||
}
|
}
|
||||||
else if (current_user_can('partenaire')) {
|
else if (current_user_can($role_partner)) {
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'post',
|
'post_type' => 'post',
|
||||||
'author' => $current_user_id,
|
'author' => $current_user_id,
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ if (!defined('ABSPATH')) {
|
|||||||
*/
|
*/
|
||||||
function add_partenaires_PLGNTLS($customer_data){
|
function add_partenaires_PLGNTLS($customer_data){
|
||||||
PLGNTLS_class::debug_infos();
|
PLGNTLS_class::debug_infos();
|
||||||
|
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
||||||
|
|
||||||
$current_url = $_SERVER['HTTP_REFERER']; // not reliable to use referer, TODO: find another solution
|
$current_url = $_SERVER['HTTP_REFERER']; // not reliable to use referer, TODO: find another solution
|
||||||
$path_brut = parse_url($current_url, PHP_URL_PATH);
|
$path_brut = parse_url($current_url, PHP_URL_PATH);
|
||||||
$path = trim($path_brut, '/');
|
$path = trim($path_brut, '/');
|
||||||
if ($path === 'creation-du-compte-partenaire')
|
if ($path === 'creation-du-compte-partenaire')
|
||||||
$customer_data['role'] = 'partenaire';
|
$customer_data['role'] = $role_partner;
|
||||||
return $customer_data;
|
return $customer_data;
|
||||||
}
|
}
|
||||||
add_filter( 'xoo_el_register_new_customer_data', 'add_partenaires_PLGNTLS', 10, 1 );
|
add_filter( 'xoo_el_register_new_customer_data', 'add_partenaires_PLGNTLS', 10, 1 );
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ function renew_page_restrictions_CIPF(){
|
|||||||
PLGNTLS_class::debug_infos();
|
PLGNTLS_class::debug_infos();
|
||||||
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
||||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||||
// $acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW;
|
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||||
|
$role_fipf = PLGNTLS_class::ROLE_FIPF;
|
||||||
|
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||||
|
|
||||||
if (!is_page($slug_renew_card))
|
if (!is_page($slug_renew_card))
|
||||||
return;
|
return;
|
||||||
@@ -72,7 +74,7 @@ function renew_page_restrictions_CIPF(){
|
|||||||
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
|
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$allowed_roles = array('administrator', 'editor', 'professeur__professeure');
|
$allowed_roles = array($role_admin, $role_fipf, $role_prof);
|
||||||
if (!array_intersect($allowed_roles, $current_user->roles))
|
if (!array_intersect($allowed_roles, $current_user->roles))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -80,7 +82,7 @@ function renew_page_restrictions_CIPF(){
|
|||||||
* if prof, check card state
|
* if prof, check card state
|
||||||
* if cannot renew, redirect
|
* if cannot renew, redirect
|
||||||
*
|
*
|
||||||
if (current_user_can('professeur__professeure')) {
|
if (current_user_can($role_prof)) {
|
||||||
$can_renew = get_field($acf_prof_can_renew['_name'], $acf_id);
|
$can_renew = get_field($acf_prof_can_renew['_name'], $acf_id);
|
||||||
if ($can_renew === false) {
|
if ($can_renew === false) {
|
||||||
$redirect_url = home_url() . '/' . $slug_page_redirection;
|
$redirect_url = home_url() . '/' . $slug_page_redirection;
|
||||||
|
|||||||
Reference in New Issue
Block a user