1930795f by Jeremy Groot

CPT UI

1 parent 7e7ce19d
Showing 32 changed files with 11508 additions and 0 deletions
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
postboxes.add_postbox_toggles(pagenow);
(function($) {
$("#cptui_select_post_type_submit").hide();
$("#cptui_select_taxonomy_submit").hide();
if ("edit" === getParameterByName("action")) {
var original_slug = $("#name").val();
}
$("#hierarchical").on("change", function() {
var hierarchical = $(this).val();
if ("1" === hierarchical) {
$("#page-attributes").prop("checked", true);
} else {
$("#page-attributes").prop("checked", false);
}
});
$("#post_type").on("change", function() {
$("#cptui_select_post_type").submit();
});
$("#taxonomy").on("change", function() {
$("#cptui_select_taxonomy").submit();
});
$(".cptui-delete-top, .cptui-delete-bottom").on("click", function(e) {
e.preventDefault();
var msg = "";
if (typeof cptui_type_data !== "undefined") {
msg = cptui_type_data.confirm;
} else if (typeof cptui_tax_data !== "undefined") {
msg = cptui_tax_data.confirm;
}
var submit_delete_warning = $('<div class="cptui-submit-delete-dialog">' + msg + "</div>").appendTo("#poststuff").dialog({
dialogClass: "wp-dialog",
modal: true,
autoOpen: true,
buttons: {
OK: function() {
var form = $(e.target).closest("form");
$(e.target).off("click").click();
},
Cancel: function() {
$(this).dialog("close");
}
}
});
});
$("#support .question").each(function() {
var tis = $(this), state = false, answer = tis.next("div").slideUp();
tis.on("click keydown", function(e) {
if (e.type === "keydown" && e.keyCode !== 32 && e.keyCode !== 13) {
return;
}
e.preventDefault();
state = !state;
answer.slideToggle(state);
tis.toggleClass("active", state);
tis.attr("aria-expanded", state.toString());
tis.focus();
});
});
$("#name").on("keyup", function(e) {
var value, original_value;
value = original_value = $(this).val();
if (e.keyCode !== 9 && e.keyCode !== 37 && e.keyCode !== 38 && e.keyCode !== 39 && e.keyCode !== 40) {
value = value.replace(/ /g, "_");
value = value.toLowerCase();
value = replaceDiacritics(value);
value = transliterate(value);
value = replaceSpecialCharacters(value);
if (value !== original_value) {
$(this).prop("value", value);
}
}
if (typeof original_slug !== "undefined") {
var $slugchanged = $("#slugchanged");
if (value != original_slug) {
$slugchanged.removeClass("hidemessage");
} else {
$slugchanged.addClass("hidemessage");
}
}
var $slugexists = $("#slugexists");
if (typeof cptui_type_data != "undefined") {
if (cptui_type_data.existing_post_types.hasOwnProperty(value) && value !== original_slug) {
$slugexists.removeClass("hidemessage");
} else {
$slugexists.addClass("hidemessage");
}
}
if (typeof cptui_tax_data != "undefined") {
if (cptui_tax_data.existing_taxonomies.hasOwnProperty(value) && value !== original_slug) {
$slugexists.removeClass("hidemessage");
} else {
$slugexists.addClass("hidemessage");
}
}
});
function replaceDiacritics(s) {
var diacritics = [ /[\300-\306]/g, /[\340-\346]/g, /[\310-\313]/g, /[\350-\353]/g, /[\314-\317]/g, /[\354-\357]/g, /[\322-\330]/g, /[\362-\370]/g, /[\331-\334]/g, /[\371-\374]/g, /[\321]/g, /[\361]/g, /[\307]/g, /[\347]/g ];
var chars = [ "A", "a", "E", "e", "I", "i", "O", "o", "U", "u", "N", "n", "C", "c" ];
for (var i = 0; i < diacritics.length; i++) {
s = s.replace(diacritics[i], chars[i]);
}
return s;
}
function replaceSpecialCharacters(s) {
s = s.replace(/[^a-z0-9\s-]/gi, "_");
return s;
}
function composePreviewContent(value) {
var re = /(http|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;
var is_url = re.test(value);
if (!value) {
return "";
} else if (0 === value.indexOf("dashicons-")) {
return $('<div class="dashicons-before"><br></div>').addClass(htmlEncode(value));
} else if (is_url) {
var imgsrc = encodeURI(value);
var theimg = document.createElement("IMG");
theimg.src = imgsrc;
return theimg;
}
}
function htmlEncode(str) {
return String(str).replace(/[^-\w. ]/gi, function(c) {
return "&#" + c.charCodeAt(0) + ";";
});
}
var cyrillic = {
"Ё": "YO",
"Й": "I",
"Ц": "TS",
"У": "U",
"К": "K",
"Е": "E",
"Н": "N",
"Г": "G",
"Ш": "SH",
"Щ": "SCH",
"З": "Z",
"Х": "H",
"Ъ": "'",
"ё": "yo",
"й": "i",
"ц": "ts",
"у": "u",
"к": "k",
"е": "e",
"н": "n",
"г": "g",
"ш": "sh",
"щ": "sch",
"з": "z",
"х": "h",
"ъ": "'",
"Ф": "F",
"Ы": "I",
"В": "V",
"А": "a",
"П": "P",
"Р": "R",
"О": "O",
"Л": "L",
"Д": "D",
"Ж": "ZH",
"Э": "E",
"ф": "f",
"ы": "i",
"в": "v",
"а": "a",
"п": "p",
"р": "r",
"о": "o",
"л": "l",
"д": "d",
"ж": "zh",
"э": "e",
"Я": "Ya",
"Ч": "CH",
"С": "S",
"М": "M",
"И": "I",
"Т": "T",
"Ь": "'",
"Б": "B",
"Ю": "YU",
"я": "ya",
"ч": "ch",
"с": "s",
"м": "m",
"и": "i",
"т": "t",
"ь": "'",
"б": "b",
"ю": "yu"
};
function transliterate(word) {
return word.split("").map(function(char) {
return cyrillic[char] || char;
}).join("");
}
if (undefined != wp.media) {
var _custom_media = true, _orig_send_attachment = wp.media.editor.send.attachment;
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url);
if (!results) return null;
if (!results[2]) return "";
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
$("#cptui_choose_icon").on("click", function(e) {
e.preventDefault();
var button = $(this);
var id = jQuery("#menu_icon").attr("id");
_custom_media = true;
wp.media.editor.send.attachment = function(props, attachment) {
if (_custom_media) {
$("#" + id).val(attachment.url).change();
} else {
return _orig_send_attachment.apply(this, [ props, attachment ]);
}
};
wp.media.editor.open(button);
return false;
});
$("#menu_icon").on("change", function() {
var value = $(this).val();
value = value.trim();
$("#menu_icon_preview").html(composePreviewContent(value));
});
$(".cptui-help").on("click", function(e) {
e.preventDefault();
});
$(".cptui-taxonomy-submit").on("click", function(e) {
if ($(".cptui-table :checkbox:checked").length == 0) {
e.preventDefault();
var no_associated_type_warning = $('<div class="cptui-taxonomy-empty-types-dialog">' + cptui_tax_data.no_associated_type + "</div>").appendTo("#poststuff").dialog({
dialogClass: "wp-dialog",
modal: true,
autoOpen: true,
buttons: {
OK: function() {
$(this).dialog("close");
}
}
});
}
});
$("#auto-populate").on("click tap", function(e) {
e.preventDefault();
var slug = $("#name").val();
var plural = $("#label").val();
var singular = $("#singular_label").val();
var fields = $('.cptui-labels input[type="text"]');
if ("" === slug) {
return;
}
if ("" === plural) {
plural = slug;
}
if ("" === singular) {
singular = slug;
}
$(fields).each(function(i, el) {
var newval = $(el).data("label");
var plurality = $(el).data("plurality");
if ("undefined" !== newval) {
if ("plural" === plurality) {
newval = newval.replace(/item/gi, plural);
} else {
newval = newval.replace(/item/gi, singular);
}
if ($(el).val() === "") {
$(el).val(newval);
}
}
});
});
$("#auto-clear").on("click tap", function(e) {
e.preventDefault();
var fields = $('.cptui-labels input[type="text"]');
$(fields).each(function(i, el) {
$(el).val("");
});
});
})(jQuery);
\ No newline at end of file
postboxes.add_postbox_toggles(pagenow),function(c){var i;function t(e){var t=/(http|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/.test(e);return e?0===e.indexOf("dashicons-")?c('<div class="dashicons-before"><br></div>').addClass(String(e).replace(/[^-\w. ]/gi,function(e){return"&#"+e.charCodeAt(0)+";"})):t?(t=encodeURI(e),(e=document.createElement("IMG")).src=t,e):void 0:""}c("#cptui_select_post_type_submit").hide(),c("#cptui_select_taxonomy_submit").hide(),"edit"===function(e,t){t=t||window.location.href;e=e.replace(/[\[\]]/g,"\\$&");e=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return e?e[2]?decodeURIComponent(e[2].replace(/\+/g," ")):"":null}("action")&&(i=c("#name").val()),c("#hierarchical").on("change",function(){"1"===c(this).val()?c("#page-attributes").prop("checked",!0):c("#page-attributes").prop("checked",!1)}),c("#post_type").on("change",function(){c("#cptui_select_post_type").submit()}),c("#taxonomy").on("change",function(){c("#cptui_select_taxonomy").submit()}),c(".cptui-delete-top, .cptui-delete-bottom").on("click",function(e){e.preventDefault();var t="";"undefined"!=typeof cptui_type_data?t=cptui_type_data.confirm:"undefined"!=typeof cptui_tax_data&&(t=cptui_tax_data.confirm),c('<div class="cptui-submit-delete-dialog">'+t+"</div>").appendTo("#poststuff").dialog({dialogClass:"wp-dialog",modal:!0,autoOpen:!0,buttons:{OK:function(){c(e.target).closest("form");c(e.target).off("click").click()},Cancel:function(){c(this).dialog("close")}}})}),c("#support .question").each(function(){var t=c(this),a=!1,i=t.next("div").slideUp();t.on("click keydown",function(e){"keydown"===e.type&&32!==e.keyCode&&13!==e.keyCode||(e.preventDefault(),a=!a,i.slideToggle(a),t.toggleClass("active",a),t.attr("aria-expanded",a.toString()),t.focus())})}),c("#name").on("keyup",function(e){var t=a=c(this).val(),a=(9!==e.keyCode&&37!==e.keyCode&&38!==e.keyCode&&39!==e.keyCode&&40!==e.keyCode&&(t=(t=function(e){for(var t=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g],a=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"],i=0;i<t.length;i++)e=e.replace(t[i],a[i]);return e}(t=(t=t.replace(/ /g,"_")).toLowerCase())).split("").map(function(e){return s[e]||e}).join(""),(t=t.replace(/[^a-z0-9\s-]/gi,"_"))!==a&&c(this).prop("value",t)),void 0!==i&&(e=c("#slugchanged"),t!=i?e.removeClass("hidemessage"):e.addClass("hidemessage")),c("#slugexists"));"undefined"!=typeof cptui_type_data&&(cptui_type_data.existing_post_types.hasOwnProperty(t)&&t!==i?a.removeClass("hidemessage"):a.addClass("hidemessage")),"undefined"!=typeof cptui_tax_data&&(cptui_tax_data.existing_taxonomies.hasOwnProperty(t)&&t!==i?a.removeClass("hidemessage"):a.addClass("hidemessage"))});var n,o,s={"Ё":"YO","Й":"I","Ц":"TS","У":"U","К":"K","Е":"E","Н":"N","Г":"G","Ш":"SH","Щ":"SCH","З":"Z","Х":"H","Ъ":"'","ё":"yo","й":"i","ц":"ts","у":"u","к":"k","е":"e","н":"n","г":"g","ш":"sh","щ":"sch","з":"z","х":"h","ъ":"'","Ф":"F","Ы":"I","В":"V","А":"a","П":"P","Р":"R","О":"O","Л":"L","Д":"D","Ж":"ZH","Э":"E","ф":"f","ы":"i","в":"v","а":"a","п":"p","р":"r","о":"o","л":"l","д":"d","ж":"zh","э":"e","Я":"Ya","Ч":"CH","С":"S","М":"M","И":"I","Т":"T","Ь":"'","Б":"B","Ю":"YU","я":"ya","ч":"ch","с":"s","м":"m","и":"i","т":"t","ь":"'","б":"b","ю":"yu"};null!=wp.media&&(n=!0,o=wp.media.editor.send.attachment),c("#cptui_choose_icon").on("click",function(e){e.preventDefault();var e=c(this),a=jQuery("#menu_icon").attr("id");return n=!0,wp.media.editor.send.attachment=function(e,t){if(!n)return o.apply(this,[e,t]);c("#"+a).val(t.url).change()},wp.media.editor.open(e),!1}),c("#menu_icon").on("change",function(){var e=(e=c(this).val()).trim();c("#menu_icon_preview").html(t(e))}),c(".cptui-help").on("click",function(e){e.preventDefault()}),c(".cptui-taxonomy-submit").on("click",function(e){0==c(".cptui-table :checkbox:checked").length&&(e.preventDefault(),c('<div class="cptui-taxonomy-empty-types-dialog">'+cptui_tax_data.no_associated_type+"</div>").appendTo("#poststuff").dialog({dialogClass:"wp-dialog",modal:!0,autoOpen:!0,buttons:{OK:function(){c(this).dialog("close")}}}))}),c("#auto-populate").on("click tap",function(e){e.preventDefault();var e=c("#name").val(),n=c("#label").val(),o=c("#singular_label").val(),t=c('.cptui-labels input[type="text"]');""!==e&&(""===n&&(n=e),""===o&&(o=e),c(t).each(function(e,t){var a=c(t).data("label"),i=c(t).data("plurality");"undefined"!==a&&(a="plural"===i?a.replace(/item/gi,n):a.replace(/item/gi,o),""===c(t).val()&&c(t).val(a))}))}),c("#auto-clear").on("click tap",function(e){e.preventDefault();e=c('.cptui-labels input[type="text"]');c(e).each(function(e,t){c(t).val("")})})}(jQuery);
\ No newline at end of file
{"version":3,"sources":["src/js/cptui-scripts.js"],"names":["postboxes","add_postbox_toggles","pagenow","$","original_slug","composePreviewContent","value","is_url","test","indexOf","addClass","String","replace","c","charCodeAt","imgsrc","encodeURI","theimg","document","createElement","src","hide","name","url","window","location","href","results","RegExp","exec","decodeURIComponent","getParameterByName","val","on","this","prop","submit","e","preventDefault","msg","cptui_type_data","confirm","cptui_tax_data","appendTo","dialog","dialogClass","modal","autoOpen","buttons","OK","target","closest","off","click","Cancel","each","tis","state","answer","next","slideUp","type","keyCode","slideToggle","toggleClass","attr","toString","focus","original_value","$slugexists","s","diacritics","chars","i","length","replaceDiacritics","toLowerCase","split","map","char","cyrillic","join","$slugchanged","removeClass","existing_post_types","hasOwnProperty","existing_taxonomies","_custom_media","_orig_send_attachment","Ё","Й","Ц","У","К","Е","Н","Г","Ш","Щ","З","Х","Ъ","ё","й","ц","у","к","е","н","г","ш","щ","з","х","ъ","Ф","Ы","В","А","П","Р","О","Л","Д","Ж","Э","ф","ы","в","а","п","р","о","л","д","ж","э","Я","Ч","С","М","И","Т","Ь","Б","Ю","я","ч","с","м","и","т","ь","б","ю","undefined","wp","media","editor","send","attachment","button","id","jQuery","props","apply","change","open","trim","html","no_associated_type","slug","plural","singular","fields","el","newval","data","plurality"],"mappings":"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"}
\ No newline at end of file
.posttypesui, .taxonomiesui {
width: calc(100% - 300px); }
.posttypesui .cptui-section:first-child, .taxonomiesui .cptui-section:first-child {
margin-top: 30px; }
.posttypesui .postbox-container, .taxonomiesui .postbox-container {
width: 100%; }
.posttypesui .postbox .toggle-indicator:before, .taxonomiesui .postbox .toggle-indicator:before {
content: "\f142";
display: inline-block;
font: normal 20px/1 dashicons;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important; }
.posttypesui .postbox.closed .handlediv .toggle-indicator::before, .taxonomiesui .postbox.closed .handlediv .toggle-indicator::before {
content: "\f140"; }
.posttypesui .postbox .hndle, .taxonomiesui .postbox .hndle {
cursor: pointer; }
.posttypesui .required, .taxonomiesui .required {
color: red; }
.cptui-table td.outer {
vertical-align: top;
width: 50%; }
.cptui-table input[type="text"] {
width: 75%; }
.cptui-table .question:hover {
cursor: pointer; }
.cptui-table th p {
font-weight: 400;
font-size: 12px; }
.cptui-table .cptui-slug-details {
margin-top: 15px; }
.cptui-table #slugchanged, .cptui-table #slugexists {
color: red;
font-weight: bold; }
.cptui-table #slugchanged.hidemessage, .cptui-table #slugexists.hidemessage {
display: none; }
.cptui-support #support .question {
font-size: 18px;
font-weight: bold; }
.cptui-support #support .question:before {
content: "\f139";
display: inline-block;
font: normal 25px/1 'dashicons';
margin-left: -25px;
position: absolute;
-webkit-font-smoothing: antialiased; }
.cptui-support #support .question.active:before {
content: "\f140"; }
.cptui-support #support .answer {
margin: 10px 0 0 20px; }
.cptui-support #support ol li {
list-style: none; }
.cptui-support #support li {
position: relative; }
.cptui-field-description {
font-style: italic; }
#cptui_select_post_type,
#cptui_select_taxonomy {
margin-top: 15px; }
.cptui_post_import,
.cptui_tax_import {
height: 200px;
margin-bottom: 10px;
resize: vertical;
width: 100%; }
.cptui_post_type_get_code,
.cptui_tax_get_code {
height: 300px;
resize: vertical; }
.about-wrap .cptui-feature {
overflow: visible !important;
*zoom: 1; }
.about-wrap .cptui-feature:before, .about-wrap .cptui-feature:after {
content: " ";
display: table; }
.about-wrap .cptui-feature:after {
clear: both; }
.about-wrap h3 + .cptui-feature {
margin-top: 0; }
.about-wrap .changelog h2 {
text-align: center; }
.about-wrap .feature-rest div {
width: 50% !important;
padding-right: 100px;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0 !important; }
.about-wrap .feature-rest div.last-feature {
padding-left: 100px;
padding-right: 0; }
.about-wrap .feature-rest div.icon {
width: 0 !important;
padding: 0;
margin: 0; }
.about-wrap .feature-rest div.icon:before {
font-weight: normal;
width: 100%;
font-size: 170px;
line-height: 125px;
color: #9c5d90;
display: inline-block;
position: relative;
text-align: center;
speak: none;
margin: 0 0 0 -100px;
content: "\e01d";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; }
.about-wrap .about-integrations {
background: #fff;
margin: 20px 0;
padding: 1px 20px 10px; }
.about-wrap .changelog h4 {
line-height: 1.4; }
.about-wrap .cptui-about-text {
margin-bottom: 1em !important;
margin-right: 0;
max-width: calc(100% - 173px); }
.email-octopus-form-row input::placeholder {
color: #cccccc; }
.email-octopus-form-row-hp {
visibility: hidden; }
.cptui-intro-devblock {
display: flex;
flex-direction: row; }
.cptui-help {
color: #424242;
margin-left: 4px;
opacity: 0.5;
text-decoration: none;
width: 16px; }
fieldset .cptui-help {
position: relative;
top: 4px; }
.cptui-help:hover {
color: #0074a2;
opacity: 1; }
.cptui-help:focus {
box-shadow: none; }
#menu_icon_preview {
float: right;
padding-left: 8px; }
#menu_icon_preview img {
display: block;
height: 20px;
width: 20px; }
.visuallyhidden {
position: absolute;
left: -10000px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden; }
.cptui-spacer {
display: block;
margin-top: 25px; }
.email-octopus-form-wrapper {
background: #fff;
margin-bottom: 10px;
padding: 20px; }
.email-octopus-form-wrapper label {
margin-bottom: 10px; }
.wdsoctosignup h2 {
text-align: left; }
.wdspromos {
float: right;
margin-left: 20px;
margin-top: 10px;
width: 275px; }
.wdspromos-about {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-content: stretch;
align-content: stretch;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
margin: 20px 0; }
.wdspromos-about a:nth-child(1) {
-ms-flex-order: 0;
order: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
-webkit-align-self: auto;
align-self: auto; }
.wdspromos-about a:nth-child(2) {
-ms-flex-order: 0;
order: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
-webkit-align-self: auto;
align-self: auto; }
.wdspromos-about a:nth-child(3) {
-ms-flex-order: 0;
order: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
-webkit-align-self: auto;
align-self: auto; }
.wdspromos-about p {
padding: 0 5px; }
.wdspromos-about p:nth-child(1) {
padding-left: 0; }
.wdspromos-about p:nth-child(4) {
padding-right: 0; }
.no-js #cptui_choose_icon {
display: none; }
.cptui-listings th {
font-weight: bold; }
.cptui-listings .post-type-listing th {
width: 16.66667%; }
.cptui-listings .taxonomy-listing th {
width: 20%; }
#poststuff {
min-width: 463px; }
.dashicon-picker-container {
position: absolute;
width: 220px;
height: 252px;
font-size: 14px;
background-color: #fff;
box-shadow: -1px 2px 5px 3px rgba(0, 0, 0, 0.41);
overflow: hidden;
padding: 5px;
box-sizing: border-box; }
.dashicon-picker-container ul {
margin: 0 0 10px;
padding: 0; }
.dashicon-picker-container ul .dashicons {
width: 20px;
height: 20px;
font-size: 20px; }
.dashicon-picker-container ul li {
display: inline-block;
margin: 5px;
float: left; }
.dashicon-picker-container ul li a {
display: block;
text-decoration: none;
color: #373737;
padding: 5px 5px;
border: 1px solid #dfdfdf; }
.dashicon-picker-container ul li a:hover {
border-color: #999;
background: #efefef; }
.dashicon-picker-control {
height: 32px; }
.dashicon-picker-control a {
padding: 5px;
text-decoration: none;
line-height: 32px;
width: 25px; }
.dashicon-picker-control a span {
display: inline;
vertical-align: middle; }
.dashicon-picker-control input {
font-size: 12px;
width: 140px; }
@media screen and (min-width: 769px) {
.cptui-badge {
margin-top: -42px;
height: 173px;
width: 173px;
color: #fafafa;
font-weight: bold;
font-size: 14px;
text-align: center;
margin-bottom: 10px;
background: url(../images/cptui-icon-173x173.png) no-repeat;
background-size: contain; } }
@media screen and (max-width: 768px) {
.cptui-table #description {
width: 100%; }
.wdspromos-about {
flex-wrap: wrap; }
.wdspromos-about p {
margin: 5px auto; }
.wdspromos-about p:nth-child(1) {
padding-left: 5px; }
.wdspromos-about p:nth-child(4) {
padding-right: 5px; }
.cptui-table td.outer {
width: 100%; }
#cptui_debug_info_email {
width: 100%; } }
/*# sourceMappingURL=cptui-styles.css.map */
\ No newline at end of file
{
"version": 3,
"file": "cptui-styles.css",
"sources": [
"../src/scss/cptui-styles.scss"
],
"names": [],
"mappings": "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"
}
\ No newline at end of file
.posttypesui,.taxonomiesui{width:calc(100% - 300px)}.posttypesui .cptui-section:first-child,.taxonomiesui .cptui-section:first-child{margin-top:30px}.posttypesui .postbox-container,.taxonomiesui .postbox-container{width:100%}.posttypesui .postbox .toggle-indicator:before,.taxonomiesui .postbox .toggle-indicator:before{content:"\f142";display:inline-block;font:normal 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none !important}.posttypesui .postbox.closed .handlediv .toggle-indicator::before,.taxonomiesui .postbox.closed .handlediv .toggle-indicator::before{content:"\f140"}.posttypesui .postbox .hndle,.taxonomiesui .postbox .hndle{cursor:pointer}.posttypesui .required,.taxonomiesui .required{color:red}.cptui-table td.outer{vertical-align:top;width:50%}.cptui-table input[type="text"]{width:75%}.cptui-table .question:hover{cursor:pointer}.cptui-table th p{font-weight:400;font-size:12px}.cptui-table .cptui-slug-details{margin-top:15px}.cptui-table #slugchanged,.cptui-table #slugexists{color:red;font-weight:bold}.cptui-table #slugchanged.hidemessage,.cptui-table #slugexists.hidemessage{display:none}.cptui-support #support .question{font-size:18px;font-weight:bold}.cptui-support #support .question:before{content:"\f139";display:inline-block;font:normal 25px/1 'dashicons';margin-left:-25px;position:absolute;-webkit-font-smoothing:antialiased}.cptui-support #support .question.active:before{content:"\f140"}.cptui-support #support .answer{margin:10px 0 0 20px}.cptui-support #support ol li{list-style:none}.cptui-support #support li{position:relative}.cptui-field-description{font-style:italic}#cptui_select_post_type,#cptui_select_taxonomy{margin-top:15px}.cptui_post_import,.cptui_tax_import{height:200px;margin-bottom:10px;resize:vertical;width:100%}.cptui_post_type_get_code,.cptui_tax_get_code{height:300px;resize:vertical}.about-wrap .cptui-feature{overflow:visible !important;*zoom:1}.about-wrap .cptui-feature:before,.about-wrap .cptui-feature:after{content:" ";display:table}.about-wrap .cptui-feature:after{clear:both}.about-wrap h3+.cptui-feature{margin-top:0}.about-wrap .changelog h2{text-align:center}.about-wrap .feature-rest div{width:50% !important;padding-right:100px;-moz-box-sizing:border-box;box-sizing:border-box;margin:0 !important}.about-wrap .feature-rest div.last-feature{padding-left:100px;padding-right:0}.about-wrap .feature-rest div.icon{width:0 !important;padding:0;margin:0}.about-wrap .feature-rest div.icon:before{font-weight:normal;width:100%;font-size:170px;line-height:125px;color:#9c5d90;display:inline-block;position:relative;text-align:center;speak:none;margin:0 0 0 -100px;content:"\e01d";-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.about-wrap .about-integrations{background:#fff;margin:20px 0;padding:1px 20px 10px}.about-wrap .changelog h4{line-height:1.4}.about-wrap .cptui-about-text{margin-bottom:1em !important;margin-right:0;max-width:calc(100% - 173px)}.email-octopus-form-row input::placeholder{color:#cccccc}.email-octopus-form-row-hp{visibility:hidden}.cptui-intro-devblock{display:flex;flex-direction:row}.cptui-help{color:#424242;margin-left:4px;opacity:0.5;text-decoration:none;width:16px}fieldset .cptui-help{position:relative;top:4px}.cptui-help:hover{color:#0074a2;opacity:1}.cptui-help:focus{box-shadow:none}#menu_icon_preview{float:right;padding-left:8px}#menu_icon_preview img{display:block;height:20px;width:20px}.visuallyhidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.cptui-spacer{display:block;margin-top:25px}.email-octopus-form-wrapper{background:#fff;margin-bottom:10px;padding:20px}.email-octopus-form-wrapper label{margin-bottom:10px}.wdsoctosignup h2{text-align:left}.wdspromos{float:right;margin-left:20px;margin-top:10px;width:275px}.wdspromos-about{display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-content:stretch;align-content:stretch;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;margin:20px 0}.wdspromos-about a:nth-child(1){-ms-flex-order:0;order:0;-webkit-flex:0 1 auto;-ms-flex:0 1 auto;flex:0 1 auto;-webkit-align-self:auto;align-self:auto}.wdspromos-about a:nth-child(2){-ms-flex-order:0;order:0;-webkit-flex:0 1 auto;-ms-flex:0 1 auto;flex:0 1 auto;-webkit-align-self:auto;align-self:auto}.wdspromos-about a:nth-child(3){-ms-flex-order:0;order:0;-webkit-flex:0 1 auto;-ms-flex:0 1 auto;flex:0 1 auto;-webkit-align-self:auto;align-self:auto}.wdspromos-about p{padding:0 5px}.wdspromos-about p:nth-child(1){padding-left:0}.wdspromos-about p:nth-child(4){padding-right:0}.no-js #cptui_choose_icon{display:none}.cptui-listings th{font-weight:bold}.cptui-listings .post-type-listing th{width:16.66667%}.cptui-listings .taxonomy-listing th{width:20%}#poststuff{min-width:463px}.dashicon-picker-container{position:absolute;width:220px;height:252px;font-size:14px;background-color:#fff;box-shadow:-1px 2px 5px 3px rgba(0,0,0,0.41);overflow:hidden;padding:5px;box-sizing:border-box}.dashicon-picker-container ul{margin:0 0 10px;padding:0}.dashicon-picker-container ul .dashicons{width:20px;height:20px;font-size:20px}.dashicon-picker-container ul li{display:inline-block;margin:5px;float:left}.dashicon-picker-container ul li a{display:block;text-decoration:none;color:#373737;padding:5px 5px;border:1px solid #dfdfdf}.dashicon-picker-container ul li a:hover{border-color:#999;background:#efefef}.dashicon-picker-control{height:32px}.dashicon-picker-control a{padding:5px;text-decoration:none;line-height:32px;width:25px}.dashicon-picker-control a span{display:inline;vertical-align:middle}.dashicon-picker-control input{font-size:12px;width:140px}@media screen and (min-width: 769px){.cptui-badge{margin-top:-42px;height:173px;width:173px;color:#fafafa;font-weight:bold;font-size:14px;text-align:center;margin-bottom:10px;background:url(../images/cptui-icon-173x173.png) no-repeat;background-size:contain}}@media screen and (max-width: 768px){.cptui-table #description{width:100%}.wdspromos-about{flex-wrap:wrap}.wdspromos-about p{margin:5px auto}.wdspromos-about p:nth-child(1){padding-left:5px}.wdspromos-about p:nth-child(4){padding-right:5px}.cptui-table td.outer{width:100%}#cptui_debug_info_email{width:100%}}
(function($) {
"use strict";
$.fn.dashiconsPicker = function() {
var icons = [ "menu", "admin-site", "dashboard", "admin-media", "admin-page", "admin-comments", "admin-appearance", "admin-plugins", "admin-users", "admin-tools", "admin-settings", "admin-network", "admin-generic", "admin-home", "admin-collapse", "filter", "admin-customizer", "admin-multisite", "admin-links", "format-links", "admin-post", "format-standard", "format-image", "format-gallery", "format-audio", "format-video", "format-chat", "format-status", "format-aside", "format-quote", "welcome-write-blog", "welcome-edit-page", "welcome-add-page", "welcome-view-site", "welcome-widgets-menus", "welcome-comments", "welcome-learn-more", "image-crop", "image-rotate", "image-rotate-left", "image-rotate-right", "image-flip-vertical", "image-flip-horizontal", "image-filter", "undo", "redo", "editor-bold", "editor-italic", "editor-ul", "editor-ol", "editor-quote", "editor-alignleft", "editor-aligncenter", "editor-alignright", "editor-insertmore", "editor-spellcheck", "editor-distractionfree", "editor-expand", "editor-contract", "editor-kitchensink", "editor-underline", "editor-justify", "editor-textcolor", "editor-paste-word", "editor-paste-text", "editor-removeformatting", "editor-video", "editor-customchar", "editor-outdent", "editor-indent", "editor-help", "editor-strikethrough", "editor-unlink", "editor-rtl", "editor-break", "editor-code", "editor-paragraph", "editor-table", "align-left", "align-right", "align-center", "align-none", "lock", "unlock", "calendar", "calendar-alt", "visibility", "hidden", "post-status", "edit", "post-trash", "trash", "sticky", "external", "arrow-up", "arrow-down", "arrow-left", "arrow-right", "arrow-up-alt", "arrow-down-alt", "arrow-left-alt", "arrow-right-alt", "arrow-up-alt2", "arrow-down-alt2", "arrow-left-alt2", "arrow-right-alt2", "leftright", "sort", "randomize", "list-view", "excerpt-view", "grid-view", "hammer", "art", "migrate", "performance", "universal-access", "universal-access-alt", "tickets", "nametag", "clipboard", "heart", "megaphone", "schedule", "wordpress", "wordpress-alt", "pressthis", "update", "screenoptions", "cart", "feedback", "cloud", "translation", "tag", "category", "archive", "tagcloud", "text", "media-archive", "media-audio", "media-code", "media-default", "media-document", "media-interactive", "media-spreadsheet", "media-text", "media-video", "playlist-audio", "playlist-video", "controls-play", "controls-pause", "controls-forward", "controls-skipforward", "controls-back", "controls-skipback", "controls-repeat", "controls-volumeon", "controls-volumeoff", "yes", "no", "no-alt", "plus", "plus-alt", "plus-alt2", "minus", "dismiss", "marker", "star-filled", "star-half", "star-empty", "flag", "info", "warning", "share", "share1", "share-alt", "share-alt2", "twitter", "rss", "email", "email-alt", "facebook", "facebook-alt", "networking", "googleplus", "location", "location-alt", "camera", "images-alt", "images-alt2", "video-alt", "video-alt2", "video-alt3", "vault", "shield", "shield-alt", "sos", "search", "slides", "analytics", "chart-pie", "chart-bar", "chart-line", "chart-area", "groups", "businessman", "id", "id-alt", "products", "awards", "forms", "testimonial", "portfolio", "book", "book-alt", "download", "upload", "backup", "clock", "lightbulb", "microphone", "desktop", "tablet", "smartphone", "phone", "smiley", "index-card", "carrot", "building", "store", "album", "palmtree", "tickets-alt", "money", "thumbs-up", "thumbs-down", "layout", "align-pull-left", "align-pull-right", "block-default", "cloud-saved", "cloud-upload", "columns", "cover-image", "embed-audio", "embed-generic", "embed-photo", "embed-post", "embed-video", "exit", "html", "info-outline", "insert-after", "insert-before", "insert", "remove", "shortcode", "table-col-after", "table-col-before", "table-col-delete", "table-row-after", "table-row-before", "table-row-delete", "saved", "amazon", "google", "linkedin", "pinterest", "podio", "reddit", "spotify", "twitch", "whatsapp", "xing", "youtube", "database-add", "database-export", "database-import", "database-remove", "database-view", "database", "bell", "airplane", "car", "calculator", "ames", "printer", "beer", "coffee", "drumstick", "food", "bank", "hourglass", "money-alt", "open-folder", "pdf", "pets", "privacy", "superhero", "superhero-alt", "edit-page", "fullscreen-alt", "fullscreen-exit-alt" ];
return this.each(function() {
var button = $(this), offsetTop, offsetLeft;
button.on("click.dashiconsPicker", function(e) {
offsetTop = $(e.currentTarget).offset().top;
offsetLeft = $(e.currentTarget).offset().left;
createPopup(button);
});
function createPopup(button) {
var target = $("#menu_icon"), preview = $(button.data("preview")), popup = $('<div class="dashicon-picker-container">' + '<div class="dashicon-picker-control"></div>' + '<ul class="dashicon-picker-list"></ul>' + "</div>").css({
top: offsetTop,
left: offsetLeft
}), list = popup.find(".dashicon-picker-list");
for (var i in icons) {
if (icons.hasOwnProperty(i)) {
list.append('<li data-icon="' + icons[i] + '"><a href="#" title="' + icons[i] + '"><span class="dashicons dashicons-' + icons[i] + '"></span></a></li>');
}
}
$("a", list).on("click", function(e) {
e.preventDefault();
var title = $(this).attr("title");
target.val("dashicons-" + title).change();
preview.prop("class", "dashicons").addClass("dashicons-" + title);
removePopup();
});
var control = popup.find(".dashicon-picker-control");
control.html('<a data-direction="back" href="#">' + '<span class="dashicons dashicons-arrow-left-alt2"></span></a>' + '<input type="text" class="" placeholder="Search" />' + '<a data-direction="forward" href="#"><span class="dashicons dashicons-arrow-right-alt2"></span></a>');
$("a", control).on("click", function(e) {
e.preventDefault();
if ($(this).data("direction") === "back") {
$("li:gt(" + (icons.length - 26) + ")", list).prependTo(list);
} else {
$("li:lt(25)", list).appendTo(list);
}
});
popup.appendTo("body").show();
$("input", control).on("keyup", function(e) {
var search = $(this).val();
if (search === "") {
$("li:lt(25)", list).show();
} else {
$("li", list).each(function() {
if ($(this).data("icon").toLowerCase().indexOf(search.toLowerCase()) !== -1) {
$(this).show();
} else {
$(this).hide();
}
});
}
});
$(document).on("mouseup.dashicons-picker", function(e) {
if (!popup.is(e.target) && popup.has(e.target).length === 0) {
removePopup();
}
});
}
function removePopup() {
$(".dashicon-picker-container").remove();
$(document).off(".dashicons-picker");
}
});
};
$(function() {
$(".dashicons-picker").dashiconsPicker();
});
})(jQuery);
\ No newline at end of file
!function(m){"use strict";m.fn.dashiconsPicker=function(){var c=["menu","admin-site","dashboard","admin-media","admin-page","admin-comments","admin-appearance","admin-plugins","admin-users","admin-tools","admin-settings","admin-network","admin-generic","admin-home","admin-collapse","filter","admin-customizer","admin-multisite","admin-links","format-links","admin-post","format-standard","format-image","format-gallery","format-audio","format-video","format-chat","format-status","format-aside","format-quote","welcome-write-blog","welcome-edit-page","welcome-add-page","welcome-view-site","welcome-widgets-menus","welcome-comments","welcome-learn-more","image-crop","image-rotate","image-rotate-left","image-rotate-right","image-flip-vertical","image-flip-horizontal","image-filter","undo","redo","editor-bold","editor-italic","editor-ul","editor-ol","editor-quote","editor-alignleft","editor-aligncenter","editor-alignright","editor-insertmore","editor-spellcheck","editor-distractionfree","editor-expand","editor-contract","editor-kitchensink","editor-underline","editor-justify","editor-textcolor","editor-paste-word","editor-paste-text","editor-removeformatting","editor-video","editor-customchar","editor-outdent","editor-indent","editor-help","editor-strikethrough","editor-unlink","editor-rtl","editor-break","editor-code","editor-paragraph","editor-table","align-left","align-right","align-center","align-none","lock","unlock","calendar","calendar-alt","visibility","hidden","post-status","edit","post-trash","trash","sticky","external","arrow-up","arrow-down","arrow-left","arrow-right","arrow-up-alt","arrow-down-alt","arrow-left-alt","arrow-right-alt","arrow-up-alt2","arrow-down-alt2","arrow-left-alt2","arrow-right-alt2","leftright","sort","randomize","list-view","excerpt-view","grid-view","hammer","art","migrate","performance","universal-access","universal-access-alt","tickets","nametag","clipboard","heart","megaphone","schedule","wordpress","wordpress-alt","pressthis","update","screenoptions","cart","feedback","cloud","translation","tag","category","archive","tagcloud","text","media-archive","media-audio","media-code","media-default","media-document","media-interactive","media-spreadsheet","media-text","media-video","playlist-audio","playlist-video","controls-play","controls-pause","controls-forward","controls-skipforward","controls-back","controls-skipback","controls-repeat","controls-volumeon","controls-volumeoff","yes","no","no-alt","plus","plus-alt","plus-alt2","minus","dismiss","marker","star-filled","star-half","star-empty","flag","info","warning","share","share1","share-alt","share-alt2","twitter","rss","email","email-alt","facebook","facebook-alt","networking","googleplus","location","location-alt","camera","images-alt","images-alt2","video-alt","video-alt2","video-alt3","vault","shield","shield-alt","sos","search","slides","analytics","chart-pie","chart-bar","chart-line","chart-area","groups","businessman","id","id-alt","products","awards","forms","testimonial","portfolio","book","book-alt","download","upload","backup","clock","lightbulb","microphone","desktop","tablet","smartphone","phone","smiley","index-card","carrot","building","store","album","palmtree","tickets-alt","money","thumbs-up","thumbs-down","layout","align-pull-left","align-pull-right","block-default","cloud-saved","cloud-upload","columns","cover-image","embed-audio","embed-generic","embed-photo","embed-post","embed-video","exit","html","info-outline","insert-after","insert-before","insert","remove","shortcode","table-col-after","table-col-before","table-col-delete","table-row-after","table-row-before","table-row-delete","saved","amazon","google","linkedin","pinterest","podio","reddit","spotify","twitch","whatsapp","xing","youtube","database-add","database-export","database-import","database-remove","database-view","database","bell","airplane","car","calculator","ames","printer","beer","coffee","drumstick","food","bank","hourglass","money-alt","open-folder","pdf","pets","privacy","superhero","superhero-alt","edit-page","fullscreen-alt","fullscreen-exit-alt"];return this.each(function(){var s,l,n=m(this);function d(){m(".dashicon-picker-container").remove(),m(document).off(".dashicons-picker")}n.on("click.dashiconsPicker",function(e){s=m(e.currentTarget).offset().top,l=m(e.currentTarget).offset().left;var a,e=n,t=m("#menu_icon"),o=m(e.data("preview")),i=m('<div class="dashicon-picker-container"><div class="dashicon-picker-control"></div><ul class="dashicon-picker-list"></ul></div>').css({top:s,left:l}),r=i.find(".dashicon-picker-list");for(a in c)c.hasOwnProperty(a)&&r.append('<li data-icon="'+c[a]+'"><a href="#" title="'+c[a]+'"><span class="dashicons dashicons-'+c[a]+'"></span></a></li>');m("a",r).on("click",function(e){e.preventDefault();e=m(this).attr("title");t.val("dashicons-"+e).change(),o.prop("class","dashicons").addClass("dashicons-"+e),d()}),(e=i.find(".dashicon-picker-control")).html('<a data-direction="back" href="#"><span class="dashicons dashicons-arrow-left-alt2"></span></a><input type="text" class="" placeholder="Search" /><a data-direction="forward" href="#"><span class="dashicons dashicons-arrow-right-alt2"></span></a>'),m("a",e).on("click",function(e){e.preventDefault(),"back"===m(this).data("direction")?m("li:gt("+(c.length-26)+")",r).prependTo(r):m("li:lt(25)",r).appendTo(r)}),i.appendTo("body").show(),m("input",e).on("keyup",function(e){var a=m(this).val();""===a?m("li:lt(25)",r).show():m("li",r).each(function(){-1!==m(this).data("icon").toLowerCase().indexOf(a.toLowerCase())?m(this).show():m(this).hide()})}),m(document).on("mouseup.dashicons-picker",function(e){i.is(e.target)||0!==i.has(e.target).length||d()})})})},m(function(){m(".dashicons-picker").dashiconsPicker()})}(jQuery);
\ No newline at end of file
{"version":3,"sources":["src/js/dashicons-picker.js"],"names":["$","fn","dashiconsPicker","icons","this","each","offsetTop","offsetLeft","button","removePopup","remove","document","off","on","e","currentTarget","offset","top","left","createPopup","i","target","preview","data","popup","css","list","find","hasOwnProperty","append","preventDefault","title","attr","val","change","prop","addClass","control","html","length","prependTo","appendTo","show","search","toLowerCase","indexOf","hide","is","has","jQuery"],"mappings":"CAMG,SAAWA,gBAMbA,EAAEC,GAAGC,gBAAkB,WAOtB,IAAIC,EAAQ,CACX,OACA,aACA,YACA,cACA,aACA,iBACA,mBACA,gBACA,cACA,cACA,iBACA,gBACA,gBACA,aACA,iBACA,SACA,mBACA,kBACA,cACA,eACA,aACA,kBACA,eACA,iBACA,eACA,eACA,cACA,gBACA,eACA,eACA,qBACA,oBACA,mBACA,oBACA,wBACA,mBACA,qBACA,aACA,eACA,oBACA,qBACA,sBACA,wBACA,eACA,OACA,OACA,cACA,gBACA,YACA,YACA,eACA,mBACA,qBACA,oBACA,oBACA,oBACA,yBACA,gBACA,kBACA,qBACA,mBACA,iBACA,mBACA,oBACA,oBACA,0BACA,eACA,oBACA,iBACA,gBACA,cACA,uBACA,gBACA,aACA,eACA,cACA,mBACA,eACA,aACA,cACA,eACA,aACA,OACA,SACA,WACA,eACA,aACA,SACA,cACA,OACA,aACA,QACA,SACA,WACA,WACA,aACA,aACA,cACA,eACA,iBACA,iBACA,kBACA,gBACA,kBACA,kBACA,mBACA,YACA,OACA,YACA,YACA,eACA,YACA,SACA,MACA,UACA,cACA,mBACA,uBACA,UACA,UACA,YACA,QACA,YACA,WACA,YACA,gBACA,YACA,SACA,gBACA,OACA,WACA,QACA,cACA,MACA,WACA,UACA,WACA,OACA,gBACA,cACA,aACA,gBACA,iBACA,oBACA,oBACA,aACA,cACA,iBACA,iBACA,gBACA,iBACA,mBACA,uBACA,gBACA,oBACA,kBACA,oBACA,qBACA,MACA,KACA,SACA,OACA,WACA,YACA,QACA,UACA,SACA,cACA,YACA,aACA,OACA,OACA,UACA,QACA,SACA,YACA,aACA,UACA,MACA,QACA,YACA,WACA,eACA,aACA,aACA,WACA,eACA,SACA,aACA,cACA,YACA,aACA,aACA,QACA,SACA,aACA,MACA,SACA,SACA,YACA,YACA,YACA,aACA,aACA,SACA,cACA,KACA,SACA,WACA,SACA,QACA,cACA,YACA,OACA,WACA,WACA,SACA,SACA,QACA,YACA,aACA,UACA,SACA,aACA,QACA,SACA,aACA,SACA,WACA,QACA,QACA,WACA,cACA,QACA,YACA,cACA,SACA,kBACA,mBACA,gBACA,cACA,eACA,UACA,cACA,cACA,gBACA,cACA,aACA,cACA,OACA,OACA,eACA,eACA,gBACA,SACA,SACA,YACA,kBACA,mBACA,mBACA,kBACA,mBACA,mBACA,QACA,SACA,SACA,WACA,YACA,QACA,SACA,UACA,SACA,WACA,OACA,UACA,eACA,kBACA,kBACA,kBACA,gBACA,WACA,OACA,WACA,MACA,aACA,OACA,UACA,OACA,SACA,YACA,OACA,OACA,YACA,YACA,cACA,MACA,OACA,UACA,YACA,gBACA,YACA,iBACA,uBAGD,OAAOC,KAAKC,KAAM,WAEjB,IACCC,EACAC,EAFGC,EAASR,EAAGI,MAgFhB,SAASK,IACRT,EAAG,8BAA+BU,SAClCV,EAAGW,UAAWC,IAAK,qBA9EpBJ,EAAOK,GAAI,wBAAyB,SAAWC,GAC9CR,EAAYN,EAAGc,EAAEC,eAAgBC,SAASC,IAC1CV,EAAaP,EAAGc,EAAEC,eAAgBC,SAASE,KAC3CC,IAgBUC,EAbWZ,EAHRA,EAKTa,EAASrB,EAAG,cACfsB,EAAUtB,EAAGQ,EAAOe,KAAM,YAC1BC,EAASxB,EAAG,kIAGDyB,IAAK,CACfR,IAAQX,EACRY,KAAQX,IAETmB,EAAOF,EAAMG,KAAM,yBAEpB,IAAUP,KAAKjB,EACTA,EAAMyB,eAAeR,IACzBM,EAAKG,OAAO,kBAAoB1B,EAAMiB,GAAK,wBAA0BjB,EAAMiB,GAAK,sCAAwCjB,EAAMiB,GAAK,sBAIrIpB,EAAG,IAAK0B,GAAOb,GAAI,QAAS,SAAWC,GACtCA,EAAEgB,iBACEC,EAAQ/B,EAAGI,MAAO4B,KAAM,SAC5BX,EAAOY,IAAK,aAAeF,GAAQG,SACnCZ,EACEa,KAAK,QAAS,aACdC,SAAU,aAAeL,GAC3BtB,OAGG4B,EAAUb,EAAMG,KAAM,6BAElBW,KAAM,yPAMdtC,EAAG,IAAKqC,GAAUxB,GAAI,QAAS,SAAWC,GACzCA,EAAEgB,iBACqC,SAAlC9B,EAAGI,MAAOmB,KAAM,aACpBvB,EAAG,UAAaG,EAAMoC,OAAS,IAAO,IAAKb,GAAOc,UAAWd,GAE7D1B,EAAG,YAAa0B,GAAOe,SAAUf,KAInCF,EAAMiB,SAAU,QAASC,OAEzB1C,EAAG,QAASqC,GAAUxB,GAAI,QAAS,SAAWC,GAC7C,IAAI6B,EAAS3C,EAAGI,MAAO6B,MACP,KAAXU,EACJ3C,EAAG,YAAa0B,GAAOgB,OAEvB1C,EAAG,KAAM0B,GAAOrB,KAAM,YAC4D,IAA5EL,EAAGI,MAAOmB,KAAM,QAASqB,cAAcC,QAASF,EAAOC,eAC3D5C,EAAGI,MAAOsC,OAEV1C,EAAGI,MAAO0C,WAMd9C,EAAGW,UAAWE,GAAI,2BAA4B,SAAWC,GACjDU,EAAMuB,GAAIjC,EAAEO,SAA6C,IAAjCG,EAAMwB,IAAKlC,EAAEO,QAASkB,QACpD9B,WAYLT,EAAG,WACFA,EAAG,qBAAsBE,oBAzZ1B,CA4ZE+C"}
\ No newline at end of file
<?php
/**
* Custom Post Type UI Admin UI.
*
* @package CPTUI
* @subpackage AdminUI
* @author WebDevStudios
* @since 1.0.0
* @license GPL-2.0+
*
* phpcs:disable WebDevStudios.All.RequireAuthor
*/
/**
* Custom Post Type UI Admin UI
*
* @since 1.0.0
*/
class cptui_admin_ui {
/**
* Return an opening `<tr>` tag.
*
* @since 1.0.0
* @since 1.13.0 Added attributes parameter
*
* @param array $atts Array of custom attributes to add to the tag.
* @return string $value Opening `<tr>` tag with attributes.
*/
public function get_tr_start( $atts = [] ) {
$atts_str = '';
if ( ! empty( $atts ) ) {
$atts_str = ' ' . $this->get_custom_attributes( $atts );
}
return '<tr' . $atts_str . '>';
}
/**
* Return a closing `</tr>` tag.
*
* @since 1.0.0
*
* @return string $value Closing `</tr>` tag.
*/
public function get_tr_end() {
return '</tr>';
}
/**
* Return an opening `<th>` tag.
*
* @since 1.0.0
* @since 1.13.0 Added attributes parameter.
*
* @param array $atts Array of attributes to add to the tag.
* @return string $value Opening `<th>` tag with attributes.
*/
public function get_th_start( $atts = [] ) {
$atts_str = '';
if ( ! empty( $atts ) ) {
$atts_str = ' ' . $this->get_custom_attributes( $atts );
}
return "<th scope=\"row\"{$atts_str}>";
}
/**
* Return a closing `</th>` tag.
*
* @since 1.0.0
*
* @return string $value Closing `</th>` tag.
*/
public function get_th_end() {
return '</th>';
}
/**
* Return an opening `<td>` tag.
*
* @since 1.0.0
* @since 1.13.0 Added attributes parameter.
*
* @param array $atts Array of attributes to add to the tag.
* @return string $value Opening `<td>` tag.
*/
public function get_td_start( $atts = [] ) {
$atts_str = '';
if ( ! empty( $atts ) ) {
$atts_str = ' ' . $this->get_custom_attributes( $atts );
}
return "<td{$atts_str}>";
}
/**
* Return a closing `</td>` tag.
*
* @since 1.0.0
*
* @return string $value Closing `</td>` tag.
*/
public function get_td_end() {
return '</td>';
}
/**
* Return an opening `<fieldset>` tag.
*
* @since 1.2.0
* @since 1.3.0 Added $args parameter.
* @since 1.13.0 Added $atts parameter
*
* @param array $args Array of arguments.
* @param array $atts Array of custom attributes for the tag.
* @return string $value Opening `<fieldset>` tag.
*/
public function get_fieldset_start( $args = [], $atts = [] ) {
$fieldset = '<fieldset';
if ( ! empty( $args['id'] ) ) {
$fieldset .= ' id="' . esc_attr( $args['id'] ) . '"';
}
if ( ! empty( $args['classes'] ) ) {
$classes = 'class="' . implode( ' ', $args['classes'] ) . '"';
$fieldset .= ' ' . $classes;
}
if ( ! empty( $args['aria-expanded'] ) ) {
$fieldset .= ' aria-expanded="' . $args['aria-expanded'] . '"';
}
if ( ! empty( $atts ) ) {
$fieldset .= ' ' . $this->get_custom_attributes( $atts );
}
$fieldset .= ' tabindex="0">';
return $fieldset;
}
/**
* Return an closing `<fieldset>` tag.
*
* @since 1.2.0
*
* @return string $value Closing `<fieldset>` tag.
*/
public function get_fieldset_end() {
return '</fieldset>';
}
/**
* Return an opening `<legend>` tag.
*
* @since 1.3.0
*
* @return string
*/
public function get_legend_start( $atts = [] ) {
$atts_str = '';
if ( ! empty( $atts ) ) {
$atts_str = ' ' . $this->get_custom_attributes( $atts );
}
return "<legend class=\"screen-reader-text\"{$atts_str}>";
}
/**
* Return a closing `</legend>` tag.
*
* @since 1.3.0
*
* @return string
*/
public function get_legend_end() {
return '</legend>';
}
/**
* Return string wrapped in a `<p>` tag.
*
* @since 1.0.0
*
* @param string $text Content to wrap in a `<p>` tag.
* @return string $value Content wrapped in a `<p>` tag.
*/
public function get_p( $text = '' ) {
return '<p>' . $text . '</p>';
}
/**
* Return a form <label> with for attribute.
*
* @since 1.0.0
*
* @param string $label_for Form input to associate `<label>` with.
* @param string $label_text Text to display in the `<label>` tag.
* @return string $value `<label>` tag with filled out parts.
*/
public function get_label( $label_for = '', $label_text = '' ) {
return '<label for="' . esc_attr( $label_for ) . '">' . wp_strip_all_tags( $label_text ) . '</label>';
}
/**
* Return an html attribute denoting a required field.
*
* @since 1.3.0
*
* @param bool $required Whether or not the field is required.
* @return string `Required` attribute.
*/
public function get_required_attribute( $required = false ) {
$attr = '';
if ( $required ) {
$attr .= 'required="true"';
}
return $attr;
}
/**
* Return a `<span>` to indicate required status, with class attribute.
*
* @since 1.0.0
*
* @return string Span tag.
*/
public function get_required_span() {
return ' <span class="required">*</span>';
}
/**
* Return an aria-required attribute set to true.
*
* @since 1.3.0
*
* @param bool $required Whether or not the field is required.
* @return string Aria required attribute
*/
public function get_aria_required( $required = false ) {
$attr = $required ? 'true' : 'false';
return 'aria-required="' . $attr . '"';
}
/**
* Return an `<a>` tag with title attribute holding help text.
*
* @since 1.0.0
*
* @param string $help_text Text to use in the title attribute.
* @return string <a> tag with filled out parts.
*/
public function get_help( $help_text = '' ) {
return '<a href="#" class="cptui-help dashicons-before dashicons-editor-help" title="' . esc_attr( $help_text ) . '"></a>';
}
/**
* Return a `<span>` tag with the help text.
*
* @since 1.3.0
*
* @param string $help_text Text to display after the input.
* @return string
*/
public function get_description( $help_text = '' ) {
return '<p class="cptui-field-description description">' . $help_text . '</p>';
}
/**
* Return a maxlength HTML attribute with a specified length.
*
* @since 1.0.0
*
* @param string $length How many characters the max length should be set to.
* @return string $value Maxlength HTML attribute.
*/
public function get_maxlength( $length = '' ) {
return 'maxlength="' . esc_attr( $length ) . '"';
}
/**
* Return a onblur HTML attribute for a specified value.
*
* @since 1.0.0
*
* @param string $text Text to place in the onblur attribute.
* @return string $value Onblur HTML attribute.
*/
public function get_onblur( $text = '' ) {
return 'onblur="' . esc_attr( $text ) . '"';
}
/**
* Return a placeholder HTML attribtue for a specified value.
*
* @since 1.3.0
*
* @param string $text Text to place in the placeholder attribute.
* @return string $value Placeholder HTML attribute.
*/
public function get_placeholder( $text = '' ) {
return 'placeholder="' . esc_attr( $text ) . '"';
}
/**
* Return a span that will only be visible for screenreaders.
*
* @since 1.3.0
*
* @param string $text Text to visually hide.
* @return string $value Visually hidden text meant for screen readers.
*/
public function get_hidden_text( $text = '' ) {
return '<span class="visuallyhidden">' . $text . '</span>';
}
/**
* Return a populated `<select>` input.
*
* @since 1.0.0
*
* @param array $args Arguments to use with the `<select>` input.
* @return string $value Complete <select> input with options and selected attribute.
*/
public function get_select_input( $args = [] ) {
$defaults = $this->get_default_input_parameters(
[
'selections' => [],
]
);
$args = wp_parse_args( $args, $defaults );
$value = '';
if ( $args['wrap'] ) {
$value = $this->get_tr_start();
$value .= $this->get_th_start();
$value .= $this->get_label( $args['name'], $args['labeltext'] );
if ( $args['required'] ) {
$value .= $this->get_required_span();
}
if ( ! empty( $args['helptext'] ) ) {
$value .= $this->get_help( $args['helptext'] );
}
$value .= $this->get_th_end();
$value .= $this->get_td_start();
}
$value .= '<select id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']">';
if ( ! empty( $args['selections']['options'] ) && is_array( $args['selections']['options'] ) ) {
foreach ( $args['selections']['options'] as $val ) {
$result = '';
$bool = disp_boolean( $val['attr'] );
if ( is_numeric( $args['selections']['selected'] ) ) {
$selected = disp_boolean( $args['selections']['selected'] );
} elseif ( in_array( $args['selections']['selected'], [ 'true', 'false' ], true ) ) {
$selected = $args['selections']['selected'];
}
if ( ! empty( $selected ) && $selected === $bool ) {
$result = ' selected="selected"';
} else {
if ( array_key_exists( 'default', $val ) && ! empty( $val['default'] ) ) {
if ( empty( $selected ) ) {
$result = ' selected="selected"';
}
}
}
if ( ! is_numeric( $args['selections']['selected'] ) && ( ! empty( $args['selections']['selected'] ) && $args['selections']['selected'] === $val['attr'] ) ) {
$result = ' selected="selected"';
}
$value .= '<option value="' . $val['attr'] . '"' . $result . '>' . $val['text'] . '</option>';
}
}
$value .= '</select>';
if ( ! empty( $args['aftertext'] ) ) {
$value .= ' ' . $this->get_description( $args['aftertext'] );
}
if ( $args['wrap'] ) {
$value .= $this->get_td_end();
$value .= $this->get_tr_end();
}
return $value;
}
/**
* Return a text input.
*
* @since 1.0.0
*
* @param array $args Arguments to use with the text input.
* @return string Complete text `<input>` with proper attributes.
*/
public function get_text_input( $args = [] ) {
$defaults = $this->get_default_input_parameters(
[
'maxlength' => '',
'onblur' => '',
]
);
$args = wp_parse_args( $args, $defaults );
$value = '';
if ( $args['wrap'] ) {
$value .= $this->get_tr_start();
$value .= $this->get_th_start();
$value .= $this->get_label( $args['name'], $args['labeltext'] );
if ( $args['required'] ) {
$value .= $this->get_required_span();
}
$value .= $this->get_th_end();
$value .= $this->get_td_start();
}
$value .= '<input type="text" id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']" value="' . $args['textvalue'] . '"';
if ( $args['maxlength'] ) {
$value .= ' ' . $this->get_maxlength( $args['maxlength'] );
}
if ( $args['onblur'] ) {
$value .= ' ' . $this->get_onblur( $args['onblur'] );
}
$value .= ' ' . $this->get_aria_required( $args['required'] );
$value .= ' ' . $this->get_required_attribute( $args['required'] );
if ( ! empty( $args['aftertext'] ) ) {
if ( $args['placeholder'] ) {
$value .= ' ' . $this->get_placeholder( $args['aftertext'] );
}
}
if ( ! empty( $args['data'] ) ) {
foreach ( $args['data'] as $dkey => $dvalue ) {
$value .= " data-{$dkey}=\"{$dvalue}\"";
}
}
$value .= ' />';
if ( ! empty( $args['aftertext'] ) ) {
$value .= $this->get_hidden_text( $args['aftertext'] );
}
if ( $args['helptext'] ) {
$value .= '<br/>' . $this->get_description( $args['helptext'] );
}
if ( $args['wrap'] ) {
$value .= $this->get_td_end();
$value .= $this->get_tr_end();
}
return $value;
}
/**
* Return a `<textarea>` input.
*
* @since 1.0.0
*
* @param array $args Arguments to use with the textarea input.
* @return string $value Complete <textarea> input with proper attributes.
*/
public function get_textarea_input( $args = [] ) {
$defaults = $this->get_default_input_parameters(
[
'rows' => '',
'cols' => '',
]
);
$args = wp_parse_args( $args, $defaults );
$value = '';
if ( $args['wrap'] ) {
$value .= $this->get_tr_start();
$value .= $this->get_th_start();
$value .= $this->get_label( $args['name'], $args['labeltext'] );
if ( $args['required'] ) {
$value .= $this->get_required_span();
}
$value .= $this->get_th_end();
$value .= $this->get_td_start();
}
$value .= '<textarea id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']" rows="' . $args['rows'] . '" cols="' . $args['cols'] . '">' . $args['textvalue'] . '</textarea>';
if ( ! empty( $args['aftertext'] ) ) {
$value .= $args['aftertext'];
}
if ( $args['helptext'] ) {
$value .= '<br/>' . $this->get_description( $args['helptext'] );
}
if ( $args['wrap'] ) {
$value .= $this->get_td_end();
$value .= $this->get_tr_end();
}
return $value;
}
/**
* Return a checkbox `<input>`.
*
* @since 1.0.0
*
* @param array $args Arguments to use with the checkbox input.
* @return string $value Complete checkbox `<input>` with proper attributes.
*/
public function get_check_input( $args = [] ) {
$defaults = $this->get_default_input_parameters(
[
'checkvalue' => '',
'checked' => 'true',
'checklisttext' => '',
'default' => false,
]
);
$args = wp_parse_args( $args, $defaults );
$value = '';
if ( $args['wrap'] ) {
$value .= $this->get_tr_start();
$value .= $this->get_th_start();
$value .= $args['checklisttext'];
if ( $args['required'] ) {
$value .= $this->get_required_span();
}
$value .= $this->get_th_end();
$value .= $this->get_td_start();
}
if ( isset( $args['checked'] ) && 'false' === $args['checked'] ) {
$value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" />';
} else {
$value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" checked="checked" />';
}
$value .= $this->get_label( $args['name'], $args['labeltext'] );
$value .= '<br/>';
if ( $args['wrap'] ) {
$value .= $this->get_td_end();
$value .= $this->get_tr_end();
}
return $value;
}
/**
* Return a button `<input>`.
*
* @since 1.3.0
*
* @param array $args Arguments to use with the button input.
* @return string Complete button `<input>`.
*/
public function get_button( $args = [] ) {
$value = '';
$classes = isset( $args['classes'] ) ? $args['classes'] : '';
$value .= '<input id="' . $args['id'] . '" class="button ' . $classes . '" type="button" value="' . $args['textvalue'] . '" />';
return $value;
}
/**
* Returns an HTML block for previewing the menu icon.
*
* @param string $menu_icon URL or a name of the dashicons class.
*
* @return string $value HTML block with a layout of the menu icon preview.
* @since 1.8.1
*/
public function get_menu_icon_preview( $menu_icon = '' ) {
$content = '';
if ( ! empty( $menu_icon ) ) {
$content = '<img src="' . $menu_icon . '">';
if ( 0 === strpos( $menu_icon, 'dashicons-' ) ) {
$content = '<div class="dashicons-before ' . $menu_icon . '"></div>';
}
}
return '<div id="menu_icon_preview">' . $content . '</div>';
}
/**
* Return some array_merged default arguments for all input types.
*
* @since 1.0.0
*
* @param array $additions Arguments array to merge with our defaults.
* @return array $value Merged arrays for our default parameters.
*/
public function get_default_input_parameters( $additions = [] ) {
return array_merge(
[
'namearray' => '',
'name' => '',
'textvalue' => '',
'labeltext' => '',
'aftertext' => '',
'helptext' => '',
'helptext_after' => false,
'required' => false,
'wrap' => true,
'placeholder' => true,
],
(array) $additions
);
}
/**
* Return combined attributes string.
*
* @param array $attributes Array of attributes to combine.
*
* @return string
* @since 1.13.0
*/
public function get_custom_attributes( $attributes = [] ) {
$formatted = [];
if ( ! empty( $attributes ) ) {
foreach ( $attributes as $key => $attribute ) {
$formatted[] = "$key=\"$attribute\"";
}
}
return implode( ' ', $formatted );
}
}
<?php
/**
* Custom Post Type UI Debug Information.
*
* @package CPTUI
* @subpackage Debugging
* @author WebDevStudios
* @since 1.2.0
* @license GPL-2.0+
*/
/**
* Custom Post Type UI Debug Info
*/
class CPTUI_Debug_Info {
/**
* Tab content for the debug info tab.
*
* @since 1.2.0
*/
public function tab_site_info() {
?>
<p><?php esc_html_e( 'If you have sought support for Custom Post Type UI on the forums, you may be requested to send the information below to the plugin developer. Simply insert the email they provided in the input field at the bottom and click the "Send debug info" button. Only the data below will be sent to them.', 'custom-post-type-ui' ); ?></p>
<label for="cptui_audit_textarea">
<textarea readonly="readonly" aria-readonly="true" id="cptui-audit-textarea" name="cptui_audit_textarea" rows="20" cols="100" class="large-text code">
<?php echo esc_html( $this->system_status() ); ?>
</textarea></label>
<?php
}
/**
* Generate the debug information content.
*
* @since 1.2.0
*
* @return string
*/
private function system_status() {
if ( ! current_user_can( 'manage_options' ) ) {
return '';
}
global $wpdb;
$theme_data = wp_get_theme();
$theme = $theme_data->Name . ' ' . $theme_data->Version; // phpcs:ignore.
ob_start();
?>
### Begin Custom Post Type UI Debug Info ###
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n"; ?>
SITE_URL: <?php echo esc_url( site_url() ) . "\n"; ?>
HOME_URL: <?php echo esc_url( home_url() ) . "\n"; ?>
WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; // phpcs:ignore. ?>
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; // phpcs:ignore. ?>
Active Theme: <?php echo $theme . "\n"; // phpcs:ignore. ?>
Registered Post Types: <?php echo implode( ', ', get_post_types( '', 'names' ) ) . "\n"; // phpcs:ignore. ?>
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
MySQL Version: <?php echo $wpdb->db_version() . "\n"; // phpcs:ignore. ?>
Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; // phpcs:ignore. ?>
Show On Front: <?php echo get_option( 'show_on_front' ) . "\n"; // phpcs:ignore. ?>
Page On Front: <?php $id = get_option( 'page_on_front' ); // phpcs:ignore.
echo get_the_title( $id ) . ' (#' . $id . ')' . "\n"; // phpcs:ignore. ?>
Page For Posts: <?php $id = get_option( 'page_for_posts' ); // phpcs:ignore.
echo get_the_title( $id ) . ' (#' . $id . ')' . "\n"; // phpcs:ignore. ?>
WordPress Memory Limit: <?php echo ( $this->num_convt( WP_MEMORY_LIMIT ) / ( 1024 ) ) . 'MB'; ?><?php echo "\n"; // phpcs:ignore. ?>
<?php
$plugins = get_plugins();
$pg_count = count( $plugins );
echo 'TOTAL PLUGINS: ' . $pg_count . "\n\n"; // phpcs:ignore.
// MU plugins.
$mu_plugins = get_mu_plugins();
if ( $mu_plugins ) :
echo "\t\t" . 'MU PLUGINS: (' . count( $mu_plugins ) . ')' . "\n\n";
foreach ( $mu_plugins as $mu_path => $mu_plugin ) {
echo "\t\t" . esc_html( $mu_plugin['Name'] ) . ': ' . esc_html( $mu_plugin['Version'] ) . "\n";
}
endif;
// Standard plugins - active.
echo "\n";
$active = get_option( 'active_plugins', [] );
$ac_count = count( $active );
$ic_count = $pg_count - $ac_count;
echo "\t\t" . 'ACTIVE PLUGINS: (' . $ac_count . ')' . "\n\n"; // phpcs:ignore.
foreach ( $plugins as $plugin_path => $plugin ) {
// If the plugin isn't active, don't show it.
if ( ! in_array( $plugin_path, $active, true ) ) {
continue;
}
echo "\t\t" . esc_html( $plugin['Name'] ) . ': ' . esc_html( $plugin['Version'] ) . "\n";
}
// Standard plugins - inactive.
echo "\n";
echo "\t\t" , 'INACTIVE PLUGINS: (' . $ic_count . ')' . "\n\n"; // phpcs:ignore.
foreach ( $plugins as $plugin_path => $plugin ) {
// If the plugin isn't active, show it here.
if ( in_array( $plugin_path, $active, true ) ) {
continue;
}
echo "\t\t" . esc_html( $plugin['Name'] ) . ': ' . esc_html( $plugin['Version'] ) . "\n";
}
// If multisite, grab network as well.
if ( is_multisite() ) :
$net_plugins = wp_get_active_network_plugins();
$net_active = get_site_option( 'active_sitewide_plugins', [] );
echo "\n";
echo 'NETWORK ACTIVE PLUGINS: (' . count( $net_plugins ) . ')' . "\n\n";
foreach ( $net_plugins as $plugin_path ) {
$plugin_base = plugin_basename( $plugin_path );
// If the plugin isn't active, don't show it.
if ( ! array_key_exists( $plugin_base, $net_active ) ) {
continue;
}
$plugin = get_plugin_data( $plugin_path );
echo esc_html( $plugin['Name'] ) . ' :' . esc_html( $plugin['Version'] ) . "\n";
}
endif;
echo "\n";
$cptui_post_types = cptui_get_post_type_data();
echo "\t\t" . 'Post Types: ' . "\n";
echo "\t\t" . wp_json_encode( $cptui_post_types ) . "\n";
echo "\n\n";
$cptui_taxonomies = cptui_get_taxonomy_data();
echo "\t\t" . 'Taxonomies: ' . "\n";
echo "\t\t" . wp_json_encode( $cptui_taxonomies ) . "\n";
echo "\n";
if ( has_action( 'cptui_custom_debug_info' ) ) {
echo "\t\t" . 'EXTRA DEBUG INFO';
}
/**
* Fires at the end of the debug info output.
*
* @since 1.3.0
*/
do_action( 'cptui_custom_debug_info' );
echo "\n";
?>
### End Debug Info ###
<?php
return ob_get_clean();
}
/**
* Helper function for number conversions.
*
* @since 1.2.0
* @access public
*
* @param mixed $v Value.
* @return int
*/
public function num_convt( $v ) {
$l = substr( $v, - 1 );
$ret = substr( $v, 0, - 1 );
switch ( strtoupper( $l ) ) {
case 'P': // Fall-through.
case 'T': // Fall-through.
case 'G': // Fall-through.
case 'M': // Fall-through.
case 'K': // Fall-through.
$ret *= 1024;
break;
default:
break;
}
return $ret;
}
/**
* Sends an email to the specified address, with the system status as the message.
*
* @since 1.2.0
*
* @param array $args Array of arguments for the method. Optional.
* @return bool
*/
public function send_email( $args = [] ) {
if ( ! isset( $args['email'] ) || ! is_email( $args['email'] ) ) {
return false;
}
stripslashes_deep( $args );
$args['email'] = sanitize_email( $args['email'] );
$message = $this->system_status();
/**
* Filters the debug email subject.
*
* @since 1.3.0
*
* @param string $value Intended email subject.
*/
$subject = apply_filters(
'cptui_debug_email_subject',
sprintf(
// translators: Placeholder will hold site home_url.
esc_html__( 'Custom Post Type UI debug information for %s', 'custom-post-type-ui' ),
esc_url( home_url( '/' ) )
)
);
$result = wp_mail( $args['email'], $subject, $message );
/**
* Fires after the debug email has been sent.
*
* @since 1.3.0
*/
do_action( 'cptui_after_debug_email_sent' );
return $result;
}
}
<?php
/**
* Custom Post Type UI.
*
* For all your post type and taxonomy needs.
*
* @package CPTUI
* @subpackage Loader
* @author WebDevStudios
* @since 0.1.0.0
* @license GPL-2.0+
*/
/**
* Plugin Name: Custom Post Type UI
* Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
* Description: Admin UI panel for registering custom post types and taxonomies
* Author: WebDevStudios
* Version: 1.13.7
* Author URI: https://webdevstudios.com/
* Text Domain: custom-post-type-ui
* Domain Path: /languages
* License: GPL-2.0+
* Requires at least: 5.9
* Requires PHP: 5.6
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
// phpcs:set WordPress.WP.I18n check_translator_comments false
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'CPT_VERSION', '1.13.7' ); // Left for legacy purposes.
define( 'CPTUI_VERSION', '1.13.7' );
define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
/**
* Load our Admin UI class that powers our form inputs.
*
* @since 1.0.0
*
* @internal
*/
function cptui_load_ui_class() {
require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php';
require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_debug_info.php';
}
add_action( 'init', 'cptui_load_ui_class' );
/**
* Set a transient used for redirection upon activation.
*
* @since 1.4.0
*/
function cptui_activation_redirect() {
// Bail if activating from network, or bulk.
if ( is_network_admin() ) {
return;
}
// Add the transient to redirect.
set_transient( 'cptui_activation_redirect', true, 30 );
}
add_action( 'activate_' . plugin_basename( __FILE__ ), 'cptui_activation_redirect' );
/**
* Redirect user to CPTUI about page upon plugin activation.
*
* @since 1.4.0
*/
function cptui_make_activation_redirect() {
if ( ! get_transient( 'cptui_activation_redirect' ) ) {
return;
}
delete_transient( 'cptui_activation_redirect' );
// Bail if activating from network, or bulk.
if ( is_network_admin() ) {
return;
}
if ( ! cptui_is_new_install() ) {
return;
}
// Redirect to CPTUI about page.
wp_safe_redirect(
add_query_arg(
[ 'page' => 'cptui_main_menu' ],
cptui_admin_url( 'admin.php?page=cptui_main_menu' )
)
);
}
add_action( 'admin_init', 'cptui_make_activation_redirect', 1 );
/**
* Flush our rewrite rules on deactivation.
*
* @since 0.8.0
*
* @internal
*/
function cptui_deactivation() {
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'cptui_deactivation' );
/**
* Register our text domain.
*
* @since 0.8.0
*
* @internal
*/
function cptui_load_textdomain() {
load_plugin_textdomain( 'custom-post-type-ui' );
}
add_action( 'init', 'cptui_load_textdomain' );
/**
* Load our main menu.
*
* Submenu items added in version 1.1.0
*
* @since 0.1.0
*
* @internal
*/
function cptui_plugin_menu() {
/**
* Filters the required capability to manage CPTUI settings.
*
* @since 1.3.0
*
* @param string $value Capability required.
*/
$capability = apply_filters( 'cptui_required_capabilities', 'manage_options' );
$parent_slug = 'cptui_main_menu';
add_menu_page( esc_html__( 'Custom Post Types', 'custom-post-type-ui' ), esc_html__( 'CPT UI', 'custom-post-type-ui' ), $capability, $parent_slug, 'cptui_settings', cptui_menu_icon() );
add_submenu_page( $parent_slug, esc_html__( 'Add/Edit Post Types', 'custom-post-type-ui' ), esc_html__( 'Add/Edit Post Types', 'custom-post-type-ui' ), $capability, 'cptui_manage_post_types', 'cptui_manage_post_types' );
add_submenu_page( $parent_slug, esc_html__( 'Add/Edit Taxonomies', 'custom-post-type-ui' ), esc_html__( 'Add/Edit Taxonomies', 'custom-post-type-ui' ), $capability, 'cptui_manage_taxonomies', 'cptui_manage_taxonomies' );
add_submenu_page( $parent_slug, esc_html__( 'Registered Types and Taxes', 'custom-post-type-ui' ), esc_html__( 'Registered Types/Taxes', 'custom-post-type-ui' ), $capability, 'cptui_listings', 'cptui_listings' );
add_submenu_page( $parent_slug, esc_html__( 'Custom Post Type UI Tools', 'custom-post-type-ui' ), esc_html__( 'Tools', 'custom-post-type-ui' ), $capability, 'cptui_tools', 'cptui_tools' );
add_submenu_page( $parent_slug, esc_html__( 'Help/Support', 'custom-post-type-ui' ), esc_html__( 'Help/Support', 'custom-post-type-ui' ), $capability, 'cptui_support', 'cptui_support' );
/**
* Fires after the default submenu pages.
*
* @since 1.3.0
*
* @param string $value Parent slug for Custom Post Type UI menu.
* @param string $capability Capability required to manage CPTUI settings.
*/
do_action( 'cptui_extra_menu_items', $parent_slug, $capability );
// Remove the default one so we can add our customized version.
remove_submenu_page( $parent_slug, 'cptui_main_menu' );
add_submenu_page( $parent_slug, esc_html__( 'About CPT UI', 'custom-post-type-ui' ), esc_html__( 'About CPT UI', 'custom-post-type-ui' ), $capability, 'cptui_main_menu', 'cptui_settings' );
}
add_action( 'admin_menu', 'cptui_plugin_menu' );
/**
* Fire our CPTUI Loaded hook.
*
* @since 1.3.0
*
* @internal Use `cptui_loaded` hook.
*/
function cptui_loaded() {
if ( class_exists( 'WPGraphQL' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'external/wpgraphql.php';
}
/**
* Fires upon plugins_loaded WordPress hook.
*
* CPTUI loads its required files on this hook.
*
* @since 1.3.0
*/
do_action( 'cptui_loaded' );
}
add_action( 'plugins_loaded', 'cptui_loaded' );
/**
* Load our submenus.
*
* @since 1.0.0
*
* @internal
*/
function cptui_create_submenus() {
require_once plugin_dir_path( __FILE__ ) . 'inc/about.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/utility.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/post-types.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/taxonomies.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/listings.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/tools.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/tools-sections/tools-post-types.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/tools-sections/tools-taxonomies.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/tools-sections/tools-get-code.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/tools-sections/tools-debug.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/support.php';
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once plugin_dir_path( __FILE__ ) . 'inc/wp-cli.php';
}
}
add_action( 'cptui_loaded', 'cptui_create_submenus' );
/**
* Fire our CPTUI init hook.
*
* @since 1.3.0
*
* @internal Use `cptui_init` hook.
*/
function cptui_init() {
/**
* Fires upon init WordPress hook.
*
* @since 1.3.0
*/
do_action( 'cptui_init' );
}
add_action( 'init', 'cptui_init' );
/**
* Enqueue CPTUI admin styles.
*
* @since 1.0.0
*
* @internal
*/
function cptui_add_styles() {
if ( wp_doing_ajax() ) {
return;
}
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_register_script( 'cptui', plugins_url( "build/cptui-scripts{$min}.js", __FILE__ ), [ 'jquery', 'jquery-ui-dialog', 'postbox' ], CPTUI_VERSION, true );
wp_register_script( 'dashicons-picker', plugins_url( "build/dashicons-picker{$min}.js", __FILE__ ), [ 'jquery'], '1.0.0', true );
wp_register_style( 'cptui-css', plugins_url( "build/cptui-styles{$min}.css", __FILE__ ), [ 'wp-jquery-ui-dialog' ], CPTUI_VERSION );
}
add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
/**
* Register our users' custom post types.
*
* @since 0.5.0
*
* @internal
*/
function cptui_create_custom_post_types() {
$cpts = get_option( 'cptui_post_types', [] );
/**
* Filters an override array of post type data to be registered instead of our saved option.
*
* @since 1.10.0
*
* @param array $value Default override value.
*/
$cpts_override = apply_filters( 'cptui_post_types_override', [] );
if ( empty( $cpts ) && empty( $cpts_override ) ) {
return;
}
// Assume good intent, and we're also not wrecking the option so things are always reversable.
if ( is_array( $cpts_override ) && ! empty( $cpts_override ) ) {
$cpts = $cpts_override;
}
/**
* Fires before the start of the post type registrations.
*
* @since 1.3.0
*
* @param array $cpts Array of post types to register.
*/
do_action( 'cptui_pre_register_post_types', $cpts );
if ( is_array( $cpts ) ) {
foreach ( $cpts as $post_type ) {
if ( ! is_string( $post_type['name'] ) ) {
$post_type['name'] = (string) $post_type['name'];
}
/**
* Filters whether or not to skip registration of the current iterated post type.
*
* Dynamic part of the filter name is the chosen post type slug.
*
* @since 1.7.0
*
* @param bool $value Whether or not to skip the post type.
* @param array $post_type Current post type being registered.
*/
if ( (bool) apply_filters( "cptui_disable_{$post_type['name']}_cpt", false, $post_type ) ) {
continue;
}
/**
* Filters whether or not to skip registration of the current iterated post type.
*
* @since 1.7.0
*
* @param bool $value Whether or not to skip the post type.
* @param array $post_type Current post type being registered.
*/
if ( (bool) apply_filters( 'cptui_disable_cpt', false, $post_type ) ) {
continue;
}
cptui_register_single_post_type( $post_type );
}
}
/**
* Fires after the completion of the post type registrations.
*
* @since 1.3.0
*
* @param array $cpts Array of post types registered.
*/
do_action( 'cptui_post_register_post_types', $cpts );
}
add_action( 'init', 'cptui_create_custom_post_types', 10 ); // Leave on standard init for legacy purposes.
/**
* Helper function to register the actual post_type.
*
* @since 1.0.0
*
* @internal
*
* @param array $post_type Post type array to register. Optional.
* @return null Result of register_post_type.
*/
function cptui_register_single_post_type( $post_type = [] ) {
/**
* Filters the map_meta_cap value.
*
* @since 1.0.0
*
* @param bool $value True.
* @param string $name Post type name being registered.
* @param array $post_type All parameters for post type registration.
*/
$post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', true, $post_type['name'], $post_type );
if ( empty( $post_type['supports'] ) ) {
$post_type['supports'] = [];
}
/**
* Filters custom supports parameters for 3rd party plugins.
*
* @since 1.0.0
*
* @param array $value Empty array to add supports keys to.
* @param string $name Post type slug being registered.
* @param array $post_type Array of post type arguments to be registered.
*/
$user_supports_params = apply_filters( 'cptui_user_supports_params', [], $post_type['name'], $post_type );
if ( is_array( $user_supports_params ) && ! empty( $user_supports_params ) ) {
if ( is_array( $post_type['supports'] ) ) {
$post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
} else {
$post_type['supports'] = [ $user_supports_params ];
}
}
$yarpp = false; // Prevent notices.
if ( ! empty( $post_type['custom_supports'] ) ) {
$custom = explode( ',', $post_type['custom_supports'] );
foreach ( $custom as $part ) {
// We'll handle YARPP separately.
if ( in_array( $part, [ 'YARPP', 'yarpp' ], true ) ) {
$yarpp = true;
continue;
}
$post_type['supports'][] = trim( $part );
}
}
if ( isset( $post_type['supports'] ) && is_array( $post_type['supports'] ) && in_array( 'none', $post_type['supports'], true ) ) {
$post_type['supports'] = false;
}
$labels = [
'name' => $post_type['label'],
'singular_name' => $post_type['singular_label'],
];
$preserved = cptui_get_preserved_keys( 'post_types' );
$preserved_labels = cptui_get_preserved_labels();
foreach ( $post_type['labels'] as $key => $label ) {
if ( ! empty( $label ) ) {
if ( 'parent' === $key ) {
$labels['parent_item_colon'] = $label;
} else {
$labels[ $key ] = $label;
}
} elseif ( empty( $label ) && in_array( $key, $preserved, true ) ) {
$singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['post_types']['plural'] ) ) ) ? 'plural' : 'singular'; // phpcs:ignore.
$label_plurality = ( 'plural' === $singular_or_plural ) ? $post_type['label'] : $post_type['singular_label'];
$labels[ $key ] = sprintf( $preserved_labels['post_types'][ $singular_or_plural ][ $key ], $label_plurality );
}
}
$has_archive = isset( $post_type['has_archive'] ) ? get_disp_boolean( $post_type['has_archive'] ) : false;
if ( $has_archive && ! empty( $post_type['has_archive_string'] ) ) {
$has_archive = $post_type['has_archive_string'];
}
$show_in_menu = get_disp_boolean( $post_type['show_in_menu'] );
if ( ! empty( $post_type['show_in_menu_string'] ) ) {
$show_in_menu = $post_type['show_in_menu_string'];
}
$rewrite = get_disp_boolean( $post_type['rewrite'] );
if ( false !== $rewrite ) {
// Core converts to an empty array anyway, so safe to leave this instead of passing in boolean true.
$rewrite = [];
$rewrite['slug'] = ! empty( $post_type['rewrite_slug'] ) ? $post_type['rewrite_slug'] : $post_type['name'];
$rewrite['with_front'] = true; // Default value.
if ( isset( $post_type['rewrite_withfront'] ) ) {
$rewrite['with_front'] = 'false' === disp_boolean( $post_type['rewrite_withfront'] ) ? false : true;
}
}
$menu_icon = ! empty( $post_type['menu_icon'] ) ? $post_type['menu_icon'] : null;
$register_meta_box_cb = ! empty( $post_type['register_meta_box_cb'] ) ? $post_type['register_meta_box_cb'] : null;
if ( in_array( $post_type['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
$post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
}
if ( ! empty( $post_type['query_var_slug'] ) ) {
$post_type['query_var'] = $post_type['query_var_slug'];
}
$menu_position = null;
if ( ! empty( $post_type['menu_position'] ) ) {
$menu_position = (int) $post_type['menu_position'];
}
$delete_with_user = null;
if ( ! empty( $post_type['delete_with_user'] ) ) {
$delete_with_user = get_disp_boolean( $post_type['delete_with_user'] );
}
$capability_type = 'post';
if ( ! empty( $post_type['capability_type'] ) ) {
$capability_type = $post_type['capability_type'];
if ( false !== strpos( $post_type['capability_type'], ',' ) ) {
$caps = array_map( 'trim', explode( ',', $post_type['capability_type'] ) );
if ( count( $caps ) > 2 ) {
$caps = array_slice( $caps, 0, 2 );
}
$capability_type = $caps;
}
}
$public = get_disp_boolean( $post_type['public'] );
if ( ! empty( $post_type['exclude_from_search'] ) ) {
$exclude_from_search = get_disp_boolean( $post_type['exclude_from_search'] );
} else {
$exclude_from_search = false === $public;
}
$queryable = ( ! empty( $post_type['publicly_queryable'] ) && isset( $post_type['publicly_queryable'] ) ) ? get_disp_boolean( $post_type['publicly_queryable'] ) : $public;
if ( empty( $post_type['show_in_nav_menus'] ) ) {
// Defaults to value of public.
$post_type['show_in_nav_menus'] = $public;
}
if ( empty( $post_type['show_in_rest'] ) ) {
$post_type['show_in_rest'] = false;
}
$rest_base = null;
if ( ! empty( $post_type['rest_base'] ) ) {
$rest_base = $post_type['rest_base'];
}
$rest_controller_class = null;
if ( ! empty( $post_type['rest_controller_class'] ) ) {
$rest_controller_class = $post_type['rest_controller_class'];
}
$rest_namespace = null;
if ( ! empty( $post_type['rest_namespace'] ) ) {
$rest_namespace = $post_type['rest_namespace'];
}
$can_export = null;
if ( ! empty( $post_type['can_export'] ) ) {
$can_export = get_disp_boolean( $post_type['can_export'] );
}
$args = [
'labels' => $labels,
'description' => $post_type['description'],
'public' => get_disp_boolean( $post_type['public'] ),
'publicly_queryable' => $queryable,
'show_ui' => get_disp_boolean( $post_type['show_ui'] ),
'show_in_nav_menus' => get_disp_boolean( $post_type['show_in_nav_menus'] ),
'has_archive' => $has_archive,
'show_in_menu' => $show_in_menu,
'delete_with_user' => $delete_with_user,
'show_in_rest' => get_disp_boolean( $post_type['show_in_rest'] ),
'rest_base' => $rest_base,
'rest_controller_class' => $rest_controller_class,
'rest_namespace' => $rest_namespace,
'exclude_from_search' => $exclude_from_search,
'capability_type' => $capability_type,
'map_meta_cap' => $post_type['map_meta_cap'],
'hierarchical' => get_disp_boolean( $post_type['hierarchical'] ),
'can_export' => $can_export,
'rewrite' => $rewrite,
'menu_position' => $menu_position,
'menu_icon' => $menu_icon,
'register_meta_box_cb' => $register_meta_box_cb,
'query_var' => $post_type['query_var'],
'supports' => $post_type['supports'],
'taxonomies' => $post_type['taxonomies'],
];
if ( true === $yarpp ) {
$args['yarpp_support'] = $yarpp;
}
/**
* Filters the arguments used for a post type right before registering.
*
* @since 1.0.0
* @since 1.3.0 Added original passed in values array
*
* @param array $args Array of arguments to use for registering post type.
* @param string $value Post type slug to be registered.
* @param array $post_type Original passed in values for post type.
*/
$args = apply_filters( 'cptui_pre_register_post_type', $args, $post_type['name'], $post_type );
return register_post_type( $post_type['name'], $args );
}
/**
* Register our users' custom taxonomies.
*
* @since 0.5.0
*
* @internal
*/
function cptui_create_custom_taxonomies() {
$taxes = get_option( 'cptui_taxonomies', [] );
/**
* Filters an override array of taxonomy data to be registered instead of our saved option.
*
* @since 1.10.0
*
* @param array $value Default override value.
*/
$taxes_override = apply_filters( 'cptui_taxonomies_override', [] );
if ( empty( $taxes ) && empty( $taxes_override ) ) {
return;
}
// Assume good intent, and we're also not wrecking the option so things are always reversable.
if ( is_array( $taxes_override ) && ! empty( $taxes_override ) ) {
$taxes = $taxes_override;
}
/**
* Fires before the start of the taxonomy registrations.
*
* @since 1.3.0
*
* @param array $taxes Array of taxonomies to register.
*/
do_action( 'cptui_pre_register_taxonomies', $taxes );
if ( is_array( $taxes ) ) {
foreach ( $taxes as $tax ) {
if ( ! is_string( $tax['name'] ) ) {
$tax['name'] = (string) $tax['name'];
}
/**
* Filters whether or not to skip registration of the current iterated taxonomy.
*
* Dynamic part of the filter name is the chosen taxonomy slug.
*
* @since 1.7.0
*
* @param bool $value Whether or not to skip the taxonomy.
* @param array $tax Current taxonomy being registered.
*/
if ( (bool) apply_filters( "cptui_disable_{$tax['name']}_tax", false, $tax ) ) {
continue;
}
/**
* Filters whether or not to skip registration of the current iterated taxonomy.
*
* @since 1.7.0
*
* @param bool $value Whether or not to skip the taxonomy.
* @param array $tax Current taxonomy being registered.
*/
if ( (bool) apply_filters( 'cptui_disable_tax', false, $tax ) ) {
continue;
}
cptui_register_single_taxonomy( $tax );
}
}
/**
* Fires after the completion of the taxonomy registrations.
*
* @since 1.3.0
*
* @param array $taxes Array of taxonomies registered.
*/
do_action( 'cptui_post_register_taxonomies', $taxes );
}
add_action( 'init', 'cptui_create_custom_taxonomies', 9 ); // Leave on standard init for legacy purposes.
/**
* Helper function to register the actual taxonomy.
*
* @since 1.0.0
*
* @internal
*
* @param array $taxonomy Taxonomy array to register. Optional.
* @return null Result of register_taxonomy.
*/
function cptui_register_single_taxonomy( $taxonomy = [] ) {
$labels = [
'name' => $taxonomy['label'],
'singular_name' => $taxonomy['singular_label'],
];
$description = '';
if ( ! empty( $taxonomy['description'] ) ) {
$description = $taxonomy['description'];
}
$preserved = cptui_get_preserved_keys( 'taxonomies' );
$preserved_labels = cptui_get_preserved_labels();
foreach ( $taxonomy['labels'] as $key => $label ) {
if ( ! empty( $label ) ) {
$labels[ $key ] = $label;
} elseif ( empty( $label ) && in_array( $key, $preserved, true ) ) {
$singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['taxonomies']['plural'] ) ) ) ? 'plural' : 'singular'; // phpcs:ignore.
$label_plurality = ( 'plural' === $singular_or_plural ) ? $taxonomy['label'] : $taxonomy['singular_label'];
$labels[ $key ] = sprintf( $preserved_labels['taxonomies'][ $singular_or_plural ][ $key ], $label_plurality );
}
}
$rewrite = get_disp_boolean( $taxonomy['rewrite'] );
if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) {
$rewrite = [];
$rewrite['slug'] = ! empty( $taxonomy['rewrite_slug'] ) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
$rewrite['with_front'] = true;
if ( isset( $taxonomy['rewrite_withfront'] ) ) {
$rewrite['with_front'] = ( 'false' === disp_boolean( $taxonomy['rewrite_withfront'] ) ) ? false : true;
}
$rewrite['hierarchical'] = false;
if ( isset( $taxonomy['rewrite_hierarchical'] ) ) {
$rewrite['hierarchical'] = ( 'true' === disp_boolean( $taxonomy['rewrite_hierarchical'] ) ) ? true : false;
}
}
if ( in_array( $taxonomy['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
$taxonomy['query_var'] = get_disp_boolean( $taxonomy['query_var'] );
}
if ( true === $taxonomy['query_var'] && ! empty( $taxonomy['query_var_slug'] ) ) {
$taxonomy['query_var'] = $taxonomy['query_var_slug'];
}
$public = ( ! empty( $taxonomy['public'] ) && false === get_disp_boolean( $taxonomy['public'] ) ) ? false : true;
$publicly_queryable = ( ! empty( $taxonomy['publicly_queryable'] ) && false === get_disp_boolean( $taxonomy['publicly_queryable'] ) ) ? false : true;
if ( empty( $taxonomy['publicly_queryable'] ) ) {
$publicly_queryable = $public;
}
$show_admin_column = ( ! empty( $taxonomy['show_admin_column'] ) && false !== get_disp_boolean( $taxonomy['show_admin_column'] ) ) ? true : false;
$show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? true : false;
if ( empty( $taxonomy['show_in_menu'] ) ) {
$show_in_menu = get_disp_boolean( $taxonomy['show_ui'] );
}
$show_in_nav_menus = ( ! empty( $taxonomy['show_in_nav_menus'] ) && false !== get_disp_boolean( $taxonomy['show_in_nav_menus'] ) ) ? true : false;
if ( empty( $taxonomy['show_in_nav_menus'] ) ) {
$show_in_nav_menus = $public;
}
$show_tagcloud = ( ! empty( $taxonomy['show_tagcloud'] ) && false !== get_disp_boolean( $taxonomy['show_tagcloud'] ) ) ? true : false;
if ( empty( $taxonomy['show_tagcloud'] ) ) {
$show_tagcloud = get_disp_boolean( $taxonomy['show_ui'] );
}
$show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? true : false;
$show_in_quick_edit = ( ! empty( $taxonomy['show_in_quick_edit'] ) && false !== get_disp_boolean( $taxonomy['show_in_quick_edit'] ) ) ? true : false;
$sort = ( ! empty( $taxonomy['sort'] ) && false !== get_disp_boolean( $taxonomy['sort'] ) ) ? true : false;
$rest_base = null;
if ( ! empty( $taxonomy['rest_base'] ) ) {
$rest_base = $taxonomy['rest_base'];
}
$rest_controller_class = null;
if ( ! empty( $taxonomy['rest_controller_class'] ) ) {
$rest_controller_class = $taxonomy['rest_controller_class'];
}
$rest_namespace = null;
if ( ! empty( $taxonomy['rest_namespace'] ) ) {
$rest_namespace = $taxonomy['rest_namespace'];
}
$meta_box_cb = null;
if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? $taxonomy['meta_box_cb'] : false;
}
$default_term = null;
if ( ! empty( $taxonomy['default_term'] ) ) {
$term_parts = explode( ',', $taxonomy['default_term'] );
if ( ! empty( $term_parts[0] ) ) {
$default_term['name'] = trim( $term_parts[0] );
}
if ( ! empty( $term_parts[1] ) ) {
$default_term['slug'] = trim( $term_parts[1] );
}
if ( ! empty( $term_parts[2] ) ) {
$default_term['description'] = trim( $term_parts[2] );
}
}
$args = [
'labels' => $labels,
'label' => $taxonomy['label'],
'description' => $description,
'public' => $public,
'publicly_queryable' => $publicly_queryable,
'hierarchical' => get_disp_boolean( $taxonomy['hierarchical'] ),
'show_ui' => get_disp_boolean( $taxonomy['show_ui'] ),
'show_in_menu' => $show_in_menu,
'show_in_nav_menus' => $show_in_nav_menus,
'show_tagcloud' => $show_tagcloud,
'query_var' => $taxonomy['query_var'],
'rewrite' => $rewrite,
'show_admin_column' => $show_admin_column,
'show_in_rest' => $show_in_rest,
'rest_base' => $rest_base,
'rest_controller_class' => $rest_controller_class,
'rest_namespace' => $rest_namespace,
'show_in_quick_edit' => $show_in_quick_edit,
'sort' => $sort,
'meta_box_cb' => $meta_box_cb,
'default_term' => $default_term,
];
$object_type = ! empty( $taxonomy['object_types'] ) ? $taxonomy['object_types'] : '';
/**
* Filters the arguments used for a taxonomy right before registering.
*
* @since 1.0.0
* @since 1.3.0 Added original passed in values array
* @since 1.6.0 Added $obect_type variable to passed parameters.
*
* @param array $args Array of arguments to use for registering taxonomy.
* @param string $value Taxonomy slug to be registered.
* @param array $taxonomy Original passed in values for taxonomy.
* @param array $object_type Array of chosen post types for the taxonomy.
*/
$args = apply_filters( 'cptui_pre_register_taxonomy', $args, $taxonomy['name'], $taxonomy, $object_type );
return register_taxonomy( $taxonomy['name'], $object_type, $args );
}
/**
* Construct and output tab navigation.
*
* @since 1.0.0
*
* @param string $page Whether it's the CPT or Taxonomy page. Optional. Default "post_types".
* @return string
*/
function cptui_settings_tab_menu( $page = 'post_types' ) {
/**
* Filters the tabs to render on a given page.
*
* @since 1.3.0
*
* @param array $value Array of tabs to render.
* @param string $page Current page being displayed.
*/
$tabs = (array) apply_filters( 'cptui_get_tabs', [], $page );
if ( empty( $tabs['page_title'] ) ) {
return '';
}
$tmpl = '<h1>%s</h1><nav class="nav-tab-wrapper wp-clearfix" aria-label="%s">%s</nav>';
$tab_output = '';
foreach ( $tabs['tabs'] as $tab ) {
$tab_output .= sprintf(
'<a class="%s" href="%s" aria-selected="%s">%s</a>',
implode( ' ', $tab['classes'] ),
$tab['url'],
$tab['aria-selected'],
$tab['text']
);
}
printf(
$tmpl, // phpcs:ignore.
$tabs['page_title'], // phpcs:ignore.
esc_attr__( 'Secondary menu', 'custom-post-type-ui' ), // phpcs:ignore
$tab_output // phpcs:ignore.
);
}
/**
* Convert our old settings to the new options keys.
*
* These are left with standard get_option/update_option function calls for legacy and pending update purposes.
*
* @since 1.0.0
*
* @internal
*
* @return bool Whether or not options were successfully updated.
*/
function cptui_convert_settings() {
if ( wp_doing_ajax() ) {
return;
}
$retval = '';
if ( false === get_option( 'cptui_post_types' ) && ( $post_types = get_option( 'cpt_custom_post_types' ) ) ) { // phpcs:ignore.
$new_post_types = [];
foreach ( $post_types as $type ) {
$new_post_types[ $type['name'] ] = $type; // This one assigns the # indexes. Named arrays are our friend.
$new_post_types[ $type['name'] ]['supports'] = ! empty( $type[0] ) ? $type[0] : []; // Especially for multidimensional arrays.
$new_post_types[ $type['name'] ]['taxonomies'] = ! empty( $type[1] ) ? $type[1] : [];
$new_post_types[ $type['name'] ]['labels'] = ! empty( $type[2] ) ? $type[2] : [];
unset(
$new_post_types[ $type['name'] ][0],
$new_post_types[ $type['name'] ][1],
$new_post_types[ $type['name'] ][2]
); // Remove our previous indexed versions.
}
$retval = update_option( 'cptui_post_types', $new_post_types );
}
if ( false === get_option( 'cptui_taxonomies' ) && ( $taxonomies = get_option( 'cpt_custom_tax_types' ) ) ) { // phpcs:ignore.
$new_taxonomies = [];
foreach ( $taxonomies as $tax ) {
$new_taxonomies[ $tax['name'] ] = $tax; // Yep, still our friend.
$new_taxonomies[ $tax['name'] ]['labels'] = $tax[0]; // Taxonomies are the only thing with.
$new_taxonomies[ $tax['name'] ]['object_types'] = $tax[1]; // "tax" in the name that I like.
unset(
$new_taxonomies[ $tax['name'] ][0],
$new_taxonomies[ $tax['name'] ][1]
);
}
$retval = update_option( 'cptui_taxonomies', $new_taxonomies );
}
if ( ! empty( $retval ) ) {
flush_rewrite_rules();
}
return $retval;
}
add_action( 'admin_init', 'cptui_convert_settings' );
/**
* Return a notice based on conditions.
*
* @since 1.0.0
*
* @param string $action The type of action that occurred. Optional. Default empty string.
* @param string $object_type Whether it's from a post type or taxonomy. Optional. Default empty string.
* @param bool $success Whether the action succeeded or not. Optional. Default true.
* @param string $custom Custom message if necessary. Optional. Default empty string.
* @return bool|string false on no message, else HTML div with our notice message.
*/
function cptui_admin_notices( $action = '', $object_type = '', $success = true, $custom = '' ) {
$class = [];
$class[] = $success ? 'updated' : 'error';
$class[] = 'notice is-dismissible';
$object_type = esc_attr( $object_type );
$messagewrapstart = '<div id="message" class="' . implode( ' ', $class ) . '"><p>';
$message = '';
$messagewrapend = '</p></div>';
if ( 'add' === $action ) {
if ( $success ) {
$message .= sprintf( esc_html__( '%s has been successfully added', 'custom-post-type-ui' ), $object_type );
} else {
$message .= sprintf( esc_html__( '%s has failed to be added', 'custom-post-type-ui' ), $object_type );
}
} elseif ( 'update' === $action ) {
if ( $success ) {
$message .= sprintf( esc_html__( '%s has been successfully updated', 'custom-post-type-ui' ), $object_type );
} else {
$message .= sprintf( esc_html__( '%s has failed to be updated', 'custom-post-type-ui' ), $object_type );
}
} elseif ( 'delete' === $action ) {
if ( $success ) {
$message .= sprintf( esc_html__( '%s has been successfully deleted', 'custom-post-type-ui' ), $object_type );
} else {
$message .= sprintf( esc_html__( '%s has failed to be deleted', 'custom-post-type-ui' ), $object_type );
}
} elseif ( 'import' === $action ) {
if ( $success ) {
$message .= sprintf( esc_html__( '%s has been successfully imported', 'custom-post-type-ui' ), $object_type );
} else {
$message .= sprintf( esc_html__( '%s has failed to be imported', 'custom-post-type-ui' ), $object_type );
}
} elseif ( 'error' === $action ) {
if ( ! empty( $custom ) ) {
$message = $custom;
}
}
if ( $message ) {
/**
* Filters the custom admin notice for CPTUI.
*
* @since 1.0.0
*
* @param string $value Complete HTML output for notice.
* @param string $action Action whose message is being generated.
* @param string $message The message to be displayed.
* @param string $messagewrapstart Beginning wrap HTML.
* @param string $messagewrapend Ending wrap HTML.
*/
return apply_filters( 'cptui_admin_notice', $messagewrapstart . $message . $messagewrapend, $action, $message, $messagewrapstart, $messagewrapend );
}
return false;
}
/**
* Return array of keys needing preserved.
*
* @since 1.0.5
*
* @param string $type Type to return. Either 'post_types' or 'taxonomies'. Optional. Default empty string.
* @return array Array of keys needing preservered for the requested type.
*/
function cptui_get_preserved_keys( $type = '' ) {
$preserved_labels = [
'post_types' => [
'add_new_item',
'edit_item',
'new_item',
'view_item',
'view_items',
'all_items',
'search_items',
'not_found',
'not_found_in_trash',
],
'taxonomies' => [
'search_items',
'popular_items',
'all_items',
'parent_item',
'parent_item_colon',
'edit_item',
'update_item',
'add_new_item',
'new_item_name',
'separate_items_with_commas',
'add_or_remove_items',
'choose_from_most_used',
],
];
return ! empty( $type ) ? $preserved_labels[ $type ] : [];
}
/**
* Return label for the requested type and label key.
*
* @since 1.0.5
*
* @deprecated
*
* @param string $type Type to return. Either 'post_types' or 'taxonomies'. Optional. Default empty string.
* @param string $key Requested label key. Optional. Default empty string.
* @param string $plural Plural verbiage for the requested label and type. Optional. Default empty string.
* @param string $singular Singular verbiage for the requested label and type. Optional. Default empty string.
* @return string Internationalized default label.
*/
function cptui_get_preserved_label( $type = '', $key = '', $plural = '', $singular = '' ) {
$preserved_labels = [
'post_types' => [
'add_new_item' => sprintf( esc_html__( 'Add new %s', 'custom-post-type-ui' ), $singular ),
'edit_item' => sprintf( esc_html__( 'Edit %s', 'custom-post-type-ui' ), $singular ),
'new_item' => sprintf( esc_html__( 'New %s', 'custom-post-type-ui' ), $singular ),
'view_item' => sprintf( esc_html__( 'View %s', 'custom-post-type-ui' ), $singular ),
'view_items' => sprintf( esc_html__( 'View %s', 'custom-post-type-ui' ), $plural ),
'all_items' => sprintf( esc_html__( 'All %s', 'custom-post-type-ui' ), $plural ),
'search_items' => sprintf( esc_html__( 'Search %s', 'custom-post-type-ui' ), $plural ),
'not_found' => sprintf( esc_html__( 'No %s found.', 'custom-post-type-ui' ), $plural ),
'not_found_in_trash' => sprintf( esc_html__( 'No %s found in trash.', 'custom-post-type-ui' ), $plural ),
],
'taxonomies' => [
'search_items' => sprintf( esc_html__( 'Search %s', 'custom-post-type-ui' ), $plural ),
'popular_items' => sprintf( esc_html__( 'Popular %s', 'custom-post-type-ui' ), $plural ),
'all_items' => sprintf( esc_html__( 'All %s', 'custom-post-type-ui' ), $plural ),
'parent_item' => sprintf( esc_html__( 'Parent %s', 'custom-post-type-ui' ), $singular ),
'parent_item_colon' => sprintf( esc_html__( 'Parent %s:', 'custom-post-type-ui' ), $singular ),
'edit_item' => sprintf( esc_html__( 'Edit %s', 'custom-post-type-ui' ), $singular ),
'update_item' => sprintf( esc_html__( 'Update %s', 'custom-post-type-ui' ), $singular ),
'add_new_item' => sprintf( esc_html__( 'Add new %s', 'custom-post-type-ui' ), $singular ),
'new_item_name' => sprintf( esc_html__( 'New %s name', 'custom-post-type-ui' ), $singular ),
'separate_items_with_commas' => sprintf( esc_html__( 'Separate %s with commas', 'custom-post-type-ui' ), $plural ),
'add_or_remove_items' => sprintf( esc_html__( 'Add or remove %s', 'custom-post-type-ui' ), $plural ),
'choose_from_most_used' => sprintf( esc_html__( 'Choose from the most used %s', 'custom-post-type-ui' ), $plural ),
],
];
return $preserved_labels[ $type ][ $key ];
}
/**
* Returns an array of translated labels, ready for use with sprintf().
*
* Replacement for cptui_get_preserved_label for the sake of performance.
*
* @since 1.6.0
*
* @return array
*/
function cptui_get_preserved_labels() {
return [
'post_types' => [
'singular' => [
'add_new_item' => esc_html__( 'Add new %s', 'custom-post-type-ui' ),
'edit_item' => esc_html__( 'Edit %s', 'custom-post-type-ui' ),
'new_item' => esc_html__( 'New %s', 'custom-post-type-ui' ),
'view_item' => esc_html__( 'View %s', 'custom-post-type-ui' ),
],
'plural' => [
'view_items' => esc_html__( 'View %s', 'custom-post-type-ui' ),
'all_items' => esc_html__( 'All %s', 'custom-post-type-ui' ),
'search_items' => esc_html__( 'Search %s', 'custom-post-type-ui' ),
'not_found' => esc_html__( 'No %s found.', 'custom-post-type-ui' ),
'not_found_in_trash' => esc_html__( 'No %s found in trash.', 'custom-post-type-ui' ),
],
],
'taxonomies' => [
'singular' => [
'parent_item' => esc_html__( 'Parent %s', 'custom-post-type-ui' ),
'parent_item_colon' => esc_html__( 'Parent %s:', 'custom-post-type-ui' ),
'edit_item' => esc_html__( 'Edit %s', 'custom-post-type-ui' ),
'update_item' => esc_html__( 'Update %s', 'custom-post-type-ui' ),
'add_new_item' => esc_html__( 'Add new %s', 'custom-post-type-ui' ),
'new_item_name' => esc_html__( 'New %s name', 'custom-post-type-ui' ),
],
'plural' => [
'search_items' => esc_html__( 'Search %s', 'custom-post-type-ui' ),
'popular_items' => esc_html__( 'Popular %s', 'custom-post-type-ui' ),
'all_items' => esc_html__( 'All %s', 'custom-post-type-ui' ),
'separate_items_with_commas' => esc_html__( 'Separate %s with commas', 'custom-post-type-ui' ),
'add_or_remove_items' => esc_html__( 'Add or remove %s', 'custom-post-type-ui' ),
'choose_from_most_used' => esc_html__( 'Choose from the most used %s', 'custom-post-type-ui' ),
],
],
];
}
<?php
namespace CPTUI;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* This class creates settings for Custom Post Type UI to show Custom Post Types in GraphQL
*/
class CPTUI_GraphQL {
/**
* @var bool
*/
protected $show_in_graphql = false;
/**
* @var string
*/
protected $graphql_single_name = '';
/**
* @var string
*/
protected $graphql_plural_name = '';
/**
* Initializes the plugin functionality
*/
public function init() {
// Post Types.
add_action( 'cptui_post_type_after_fieldsets', [ $this, 'add_graphql_post_type_settings' ], 10, 1 );
add_filter( 'cptui_before_update_post_type', [ $this, 'before_update_post_type' ], 10, 2 );
add_filter( 'cptui_pre_register_post_type', [ $this, 'add_graphql_settings_to_registry' ], 10, 3 );
add_filter( 'cptui_pre_save_post_type', [ $this, 'save_graphql_settings' ], 10, 2 );
// Taxonomies.
add_action( 'cptui_taxonomy_after_fieldsets', [ $this, 'add_taxonomy_graphql_settings' ], 10, 1 );
add_filter( 'cptui_before_update_taxonomy', [ $this, 'before_update_taxonomy' ], 10, 2 );
add_filter( 'cptui_pre_register_taxonomy', [ $this, 'add_graphql_settings_to_registry' ], 10, 3 );
add_filter( 'cptui_pre_save_taxonomy', [ $this, 'save_graphql_settings' ], 10, 2 );
}
/**
* Adds the GraphQL Settings from CPT UI to the post_type and taxonomy registry args.
*
* @param array $args The args for the registry.
* @param string $name The name of the type.
* @param array $type The array that composes the Type.
*
* @return array
*/
public function add_graphql_settings_to_registry( $args, $name, $type ) {
// If the type is not set to show_in_graphql, return the args as-is.
if ( ! isset( $type['show_in_graphql'] ) || true !== (bool) $type['show_in_graphql'] ) {
return $args;
}
// If the type has no graphql_plural_name, return the args as-is, but
// add a message to the debug log for why the Type is not in the Schema.
if ( ! isset( $type['graphql_plural_name'] ) || empty( $type['graphql_plural_name'] ) ) {
graphql_debug(
sprintf(
// phpcs:ignore.
esc_attr__( 'The graphql_plural_name is empty for the "%s" Post Type or Taxonomy registered by Custom Post Type UI.' ),
$type['name']
)
);
return $args;
}
// If the type has no graphql_single_name, return the args as-is, but
// add a message to the debug log for why the Type is not in the Schema.
if ( ! isset( $type['graphql_single_name'] ) || empty( $type['graphql_single_name'] ) ) {
graphql_debug(
sprintf(
// phpcs:ignore.
esc_attr__( 'The graphql_single_name is empty for the "%s" Post Type or Taxonomy registered by Custom Post Type UI.' ),
$type['name']
)
);
return $args;
}
$args['show_in_graphql'] = isset( $type['show_in_graphql'] ) ? (bool) $type['show_in_graphql'] : false;
$args['graphql_single_name'] = ! empty( $type['graphql_single_name'] ) ? $type['graphql_single_name'] : null;
$args['graphql_plural_name'] = ! empty( $type['graphql_plural_name'] ) ? $type['graphql_plural_name'] : null;
return $args;
}
/**
* Capture post type settings from form submission for saving
*
* @param array $data
*/
public function before_update_post_type( $data ) {
$this->show_in_graphql = isset( $data['cpt_custom_post_type']['show_in_graphql'] ) ? $data['cpt_custom_post_type']['show_in_graphql'] : false;
$this->graphql_single_name = isset( $data['cpt_custom_post_type']['graphql_single_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_post_type']['graphql_single_name'] ) : '';
$this->graphql_plural_name = isset( $data['cpt_custom_post_type']['graphql_plural_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_post_type']['graphql_plural_name'] ) : '';
}
/**
* Capture taxonomy settings from form submission for saving
*
* @param array $data
*/
public function before_update_taxonomy( $data ) {
$this->show_in_graphql = isset( $data['cpt_custom_tax']['show_in_graphql'] ) ? $data['cpt_custom_tax']['show_in_graphql'] : false;
$this->graphql_single_name = isset( $data['cpt_custom_tax']['graphql_single_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_tax']['graphql_single_name'] ) : '';
$this->graphql_plural_name = isset( $data['cpt_custom_tax']['graphql_plural_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_tax']['graphql_plural_name'] ) : '';
}
/**
* Save values from form submission
*
* @param array $type
* @param string $name
*
* @return array
*/
public function save_graphql_settings( $type, $name ) {
$type[ $name ]['show_in_graphql'] = $this->show_in_graphql;
$type[ $name ]['graphql_single_name'] = \WPGraphQL\Utils\Utils::format_type_name( $this->graphql_single_name );
$type[ $name ]['graphql_plural_name'] = \WPGraphQL\Utils\Utils::format_type_name( $this->graphql_plural_name );
return $type;
}
/**
* Add settings fields to Custom Post Type UI form
*
* @param cptui_admin_ui $ui Admin UI instance.
*/
public function add_graphql_post_type_settings( $ui ) {
$tab = ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) ? 'edit' : 'new'; // phpcs:ignore WordPress.Security.NonceVerification
$current = [];
$name_array = 'cpt_custom_post_type';
if ( 'edit' === $tab ) {
$post_types = cptui_get_post_type_data();
$selected_post_type = cptui_get_current_post_type( false );
if ( $selected_post_type ) {
if ( array_key_exists( $selected_post_type, $post_types ) ) {
$current = $post_types[ $selected_post_type ];
}
}
}
echo $this->get_setting_fields( $ui, $current, $name_array ); // phpcs:ignore.
}
/**
* Add settings fields to Custom Post Type UI form
*
* @param cptui_admin_ui $ui Admin UI instance.
*/
public function add_taxonomy_graphql_settings( $ui ) {
$tab = ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) ? 'edit' : 'new'; // phpcs:ignore WordPress.Security.NonceVerification
$name_array = 'cpt_custom_tax';
$current = [];
if ( 'edit' === $tab ) {
$taxonomies = cptui_get_taxonomy_data();
$selected_taxonomy = cptui_get_current_taxonomy( false );
if ( $selected_taxonomy ) {
if ( array_key_exists( $selected_taxonomy, $taxonomies ) ) {
$current = $taxonomies[ $selected_taxonomy ];
}
}
}
echo $this->get_setting_fields( $ui, $current, $name_array ); // phpcs:ignore.
}
/**
* Get the settings fields to render for the form
*
* @param cptui_admin_ui $ui Admin UI instance.
* @param array $current
* @param string $name_array
*/
public function get_setting_fields( $ui, $current, $name_array ) {
?>
<div class="cptui-section postbox">
<div class="postbox-header">
<h2 class="hndle ui-sortable-handle">
<span><?php esc_html_e( 'WPGraphQL', 'wp-graphql-custom-post-type-ui' ); ?></span>
</h2>
<div class="handle-actions hide-if-no-js">
<button type="button" class="handlediv">
<span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: GraphQL Settings', 'wp-graphql-custom-post-type-ui' ); ?></span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</div>
</div>
<div class="inside">
<div class="main">
<table class="form-table cptui-table">
<?php
$selections = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'wp-graphql-custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'wp-graphql-custom-post-type-ui' ),
],
],
];
$selected = ( isset( $current ) && ! empty( $current['show_in_graphql'] ) ) ? disp_boolean( $current['show_in_graphql'] ) : '';
$selections['selected'] = ( ! empty( $selected ) && ! empty( $current['show_in_graphql'] ) ) ? $current['show_in_graphql'] : '0';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => $name_array,
'name' => 'show_in_graphql',
'labeltext' => esc_html__( 'Show in GraphQL', 'wp-graphql-custom-post-type-ui' ),
'aftertext' => esc_html__( 'Whether or not to show data of this type in the WPGraphQL. Default: false', 'wp-graphql-custom-post-type-ui' ),
'selections' => $selections, // phpcs:ignore.
'default' => false,
'required' => true,
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => $name_array,
'name' => 'graphql_single_name',
'labeltext' => esc_html__( 'GraphQL Single Name', 'wp-graphql-custom-post-type-ui' ),
'aftertext' => esc_attr__( 'Singular name for reference in the GraphQL API.', 'wp-graphql-custom-post-type-ui' ),
'textvalue' => ( isset( $current['graphql_single_name'] ) ) ? esc_attr( $current['graphql_single_name'] ) : '', // phpcs:ignore.
'required' => true,
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => $name_array,
'name' => 'graphql_plural_name',
'labeltext' => esc_html__( 'GraphQL Plural Name', 'wp-graphql-custom-post-type-ui' ),
'aftertext' => esc_attr__( 'Plural name for reference in the GraphQL API.', 'wp-graphql-custom-post-type-ui' ),
'textvalue' => ( isset( $current['graphql_plural_name'] ) ) ? esc_attr( $current['graphql_plural_name'] ) : '', // phpcs:ignore.
'required' => true,
]
);
?>
</table>
</div>
</div>
</div>
<?php
$this->graphql_field_helpers();
}
/**
* JavaScript helpers to add conditional logic and support for the GraphQL setting fields
*/
public function graphql_field_helpers() {
// This script provides helpers for the GraphQL fields in the CPT UI screen.
// If the Post Type or Taxonomy is not set to show_in_graphql the single/plural names
// should not be required.
?>
<script type="application/javascript">
let singleName = document.getElementById('graphql_single_name');
let singleNameRow = singleName.closest('tr');
let pluralName = document.getElementById('graphql_plural_name');
let pluralNameRow = pluralName.closest('tr');
let showInGraphQL = document.getElementById('show_in_graphql');
let label = document.getElementById('label');
let singleLabel = document.getElementById('singular_label');
// Set the values of the GraphQL fields and their display state
function updateGraphQlFields() {
// Set default state for field values and display state
// If the show_in_graphql value is true (or '1') show the
// fields and set them as required
// Else hide the fields and leave them as not-required
if (showInGraphQL.value === '1') {
singleName.required = true;
pluralName.required = true;
pluralNameRow.style.display = "table-row";
singleNameRow.style.display = "table-row";
} else {
singleName.required = false;
pluralName.required = false;
pluralNameRow.style.display = "none";
singleNameRow.style.display = "none";
}
// If single_name has no value, but single_label does, use single_label as the value
if (!singleName.value.length) {
singleName.value = singleLabel.value;
}
// If single_name has no value, but single_label does, use single_label as the value
if (!pluralName.value.length) {
pluralName.value = label.value;
}
}
// Once the DOM is ready, listen for events
document.addEventListener("DOMContentLoaded", function () {
updateGraphQlFields();
// When the show in graphql field changes, re-apply GraphQL Field Values
showInGraphQL.addEventListener('input', function () {
updateGraphQlFields();
});
});
</script>
<?php
}
}
/**
* Load WPGraphQL for CPT UI
*/
add_action( 'cptui_loaded', __NAMESPACE__ . '\cptui_graphql_init' );
function cptui_graphql_init() {
if ( class_exists( 'WPGraphQL_CPT_UI' ) ) {
add_action(
'admin_notices',
function () {
$link = trailingslashit( admin_url() ) . 'plugins.php';
?>
<div class="notice notice-error">
<p>
<?php
echo sprintf(
// phpcs:ignore.
esc_html__( 'Custom Post Type UI has native support for WPGraphQL. Please <a href="%s">de-active</a> the "WPGraphQL for Custom Post Type UI" extension to proceed.', 'custom-post-type-ui' ),
$link // phpcs:ignore.
);
?>
</p>
</div>
<?php
}
);
return;
}
$wpgraphql_cpt_ui = new CPTUI_GraphQL();
$wpgraphql_cpt_ui->init();
}
<?php
/**
* Custom Post Type UI About Page.
*
* @package CPTUI
* @subpackage About
* @author WebDevStudios
* @since 1.3.0
* @license GPL-2.0+
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Enqueue our Custom Post Type UI assets.
*
* @since 1.6.0
*/
function cptui_about_assets() {
$current_screen = get_current_screen();
if ( ! is_object( $current_screen ) || 'toplevel_page_cptui_main_menu' !== $current_screen->base ) {
return;
}
if ( wp_doing_ajax() ) {
return;
}
wp_enqueue_style( 'cptui-css' );
}
add_action( 'admin_enqueue_scripts', 'cptui_about_assets' );
/**
* Display our primary menu page.
*
* @since 0.3.0
*
* @internal
*/
function cptui_settings() {
?>
<div class="wrap about-wrap">
<?php
/**
* Fires inside and at the top of the wrapper for the main plugin landing page.
*
* @since 1.0.0
*/
do_action( 'cptui_main_page_start' );
?>
<h1><?php esc_html_e( 'Custom Post Type UI', 'custom-post-type-ui' ); ?> <?php echo esc_html( CPTUI_VERSION ); ?></h1>
<?php
/**
* Fires after the main page `<h1>` heading tag.
*
* @since 1.3.0
*/
do_action( 'cptui_main_page_after_header' );
?>
<div class="cptui-intro-devblock">
<p class="about-text cptui-about-text">
<?php esc_html_e( 'Thank you for choosing Custom Post Type UI! We hope that your experience with our plugin makes creating post types and taxonomies and organizing your content quick and easy.', 'custom-post-type-ui' ); ?>
</p>
<div class="cptui-badge"></div>
</div>
<?php
/**
* Fires before the About Page changelog.
*
* @since 1.4.0
*/
do_action( 'cptui_main_page_before_changelog' );
?>
<h2>
<?php
printf(
// translators: Placeholder will hold the plugin version.
esc_html__( "What's new in version %s", 'custom-post-type-ui' ),
esc_html( CPTUI_VERSION )
);
?>
</h2>
<div class="changelog about-integrations">
<div class="cptui-feature feature-section col three-col">
<div class="col">
<h2><?php esc_html_e( 'Post type descriptions', 'custom-post-type-ui' ); ?></h2>
<p><?php esc_html_e( 'We have updated a number of details around the post type description field. First we addressed issues with the Tools area when descriptions included quotes. Second we fixed an issue around stripping HTML from the field from previous security updates.', 'custom-post-type-ui' ); ?></p>
<h2><?php esc_html_e( 'Miscellaneous code cleanup and separation.', 'custom-post-type-ui' ); ?></h2>
<p><?php esc_html_e( 'Largely under the hood, but we have done some separation of our code and done more to help ensure code quality.', 'custom-post-type-ui' ); ?></p>
<h2><?php esc_html_e( 'Branding.', 'custom-post-type-ui' ); ?></h2>
<p><?php esc_html_e( 'We updated our branding for the plugin. Both within our UI but also on WordPress.org', 'custom-post-type-ui' ); ?></p>
<h2><?php esc_html_e( 'Miscellaneous.', 'custom-post-type-ui' ); ?></h2>
<p><?php esc_html_e( 'Added notes about some post type features also needing theme support declared for them to work. Fixed a pluralization issue with our UI and forms.', 'custom-post-type-ui' ); ?></p>
</div>
</div>
</div>
<div class="extranotes">
<?php
/**
* Fires inside a div for extra notes.
*
* @since 1.3.0
*/
do_action( 'cptui_main_page_extra_notes' );
?>
</div>
</div>
<?php
}
/**
* Display Pluginize-based content.
*
* @since 1.4.0
*/
function cptui_pluginize_content() {
// translators: Placeholder will hold the name of the author of the plugin.
echo '<h1>' . sprintf( esc_html__( 'More from %s', 'custom-post-type-ui' ), 'WebDevStudios' ) . '</h1>';
echo '<div class="wdspromos-about">';
$ads = cptui_get_ads();
if ( ! empty( $ads ) ) {
foreach ( $ads as $ad ) {
$the_ad = sprintf(
'<img src="%s" alt="%s">',
esc_attr( $ad['image'] ),
esc_attr( $ad['text'] )
);
// Escaping $the_ad breaks the html.
printf(
'<p><a href="%s">%s</a></p>',
esc_url( $ad['url'] ),
$the_ad // phpcs:ignore
);
}
}
echo '</div>';
}
add_action( 'cptui_main_page_extra_notes', 'cptui_pluginize_content', 9 );
/**
* Render our newsletter form for the about page.
*
* @since 1.4.0
*/
function cptui_about_page_newsletter() {
if ( cptui_is_new_install() ) {
return '';
}
?>
<div class='wdsoctosignup'>
<?php
cptui_newsletter_form();
?>
</div>
<?php
return '';
}
add_action( 'cptui_main_page_before_changelog', 'cptui_about_page_newsletter' );
/**
* Marks site as not new at the end of the about/main page.
*
* Can't be done on activation or else cptui_is_new_install() will immediately start
* returning false. So we'll do it at the end of the redirected landing page.
*
* @since 1.5.0
*/
function cptui_mark_not_new() {
if ( cptui_is_new_install() ) {
cptui_set_not_new_install();
}
}
add_action( 'cptui_main_page_extra_notes', 'cptui_mark_not_new', 999 );
<?php
/**
* Custom Post Type UI Registered Content.
*
* @package CPTUI
* @subpackage Listings
* @author WebDevStudios
* @since 1.1.0
* @license GPL-2.0+
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Enqueue our Custom Post Type UI assets.
*
* @since 1.6.0
*/
function cptui_listings_assets() {
$current_screen = get_current_screen();
if ( ! is_object( $current_screen ) || 'cpt-ui_page_cptui_listings' !== $current_screen->base ) {
return;
}
if ( wp_doing_ajax() ) {
return;
}
wp_enqueue_style( 'cptui-css' );
}
add_action( 'admin_enqueue_scripts', 'cptui_listings_assets' );
/**
* Output the content for the "Registered Types/Taxes" page.
*
* @since 1.1.0
*
* @internal
*/
function cptui_listings() {
?>
<div class="wrap cptui-listings">
<?php
/**
* Fires right inside the wrap div for the listings screen.
*
* @since 1.3.0
*/
do_action( 'cptui_inside_listings_wrap' );
?>
<h1 class="wp-heading-inline"><?php esc_html_e( 'Content types registered with Custom Post Type UI.', 'custom-post-type-ui' ); ?></h1>
<a href="<?php echo esc_url( cptui_get_add_new_link( 'post_types' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Add New Post Type', 'custom-post-type-ui' ); ?></a>
<a href="<?php echo esc_url( cptui_get_add_new_link( 'taxonomies' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Add New Taxonomy', 'custom-post-type-ui' ); ?></a>
<?php
$post_types = cptui_get_post_type_data();
echo '<h2 id="post-types">' . esc_html__( 'Post Types', 'custom-post-type-ui' ) . '</h2>';
if ( ! empty( $post_types ) ) {
?>
<p>
<?php
printf(
/* translators: %s: Total count of registered CPTUI post types */
esc_html__( 'Custom Post Type UI registered post types count total: %d', 'custom-post-type-ui' ),
count( $post_types )
);
?>
</p>
<?php
$post_type_table_heads = [
esc_html__( 'Post Type', 'custom-post-type-ui' ),
esc_html__( 'Settings', 'custom-post-type-ui' ),
esc_html__( 'Supports', 'custom-post-type-ui' ),
esc_html__( 'Taxonomies', 'custom-post-type-ui' ),
esc_html__( 'Labels', 'custom-post-type-ui' ),
esc_html__( 'Template Hierarchy', 'custom-post-type-ui' ),
];
/**
* Fires before the listing of registered post type data.
*
* @since 1.1.0
*/
do_action( 'cptui_before_post_type_listing' );
?>
<table class="wp-list-table widefat post-type-listing">
<thead>
<tr>
<?php
foreach ( $post_type_table_heads as $head ) {
echo '<th>' . esc_html( $head ) . '</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
$counter = 1;
foreach ( $post_types as $post_type => $post_type_settings ) {
$rowclass = ( 0 === $counter % 2 ) ? '' : 'alternate';
$strings = [];
$supports = [];
$taxonomies = [];
$archive = '';
foreach ( $post_type_settings as $settings_key => $settings_value ) {
if ( 'labels' === $settings_key ) {
continue;
}
if ( is_string( $settings_value ) ) {
$strings[ $settings_key ] = $settings_value;
} else {
if ( 'supports' === $settings_key ) {
$supports[ $settings_key ] = $settings_value;
}
if ( 'taxonomies' === $settings_key ) {
$taxonomies[ $settings_key ] = $settings_value;
// In case they are not associated from the post type settings.
if ( empty( $taxonomies['taxonomies'] ) ) {
$taxonomies['taxonomies'] = get_object_taxonomies( $post_type );
}
}
}
$archive = get_post_type_archive_link( $post_type );
}
?>
<tr class="<?php echo esc_attr( $rowclass ); ?>">
<?php
$edit_path = 'admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type;
$post_type_link_url = is_network_admin() ? network_admin_url( $edit_path ) : admin_url( $edit_path );
?>
<td>
<?php
printf(
'<a href="%s">%s</a><br/>
<a href="%s">%s</a><br/>',
esc_attr( $post_type_link_url ),
sprintf(
/* translators: %s: Post type slug */
esc_html__( 'Edit %1$s (%2$s)', 'custom-post-type-ui' ),
esc_html( $post_type_settings['label'] ),
esc_html( $post_type )
),
esc_attr( admin_url( 'admin.php?page=cptui_tools&action=get_code#' . $post_type ) ),
esc_html__( 'Get code', 'custom-post-type-ui' )
);
if ( $archive ) {
?>
<a href="<?php echo esc_attr( get_post_type_archive_link( $post_type ) ); ?>"><?php esc_html_e( 'View frontend archive', 'custom-post-type-ui' ); ?></a>
<?php } ?>
</td>
<td>
<?php
foreach ( $strings as $key => $value ) {
printf( '<strong>%s:</strong> ', esc_html( $key ) );
if ( in_array( $value, [ '1', '0' ], true ) ) {
echo esc_html( disp_boolean( $value ) );
} else {
echo ! empty( $value ) ? esc_html( $value ) : '""';
}
echo '<br/>';
}
?>
</td>
<td>
<?php
foreach ( $supports['supports'] as $support ) {
echo esc_html( $support ) . '<br/>';
}
?>
</td>
<td>
<?php
if ( ! empty( $taxonomies['taxonomies'] ) ) {
foreach ( $taxonomies['taxonomies'] as $taxonomy ) {
echo esc_html( $taxonomy ) . '<br/>';
}
} else {
printf(
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
esc_html__( 'No associated taxonomies', 'custom-post-type-ui' )
);
}
?>
</td>
<td>
<?php
$maybe_empty = array_filter( $post_type_settings['labels'] );
if ( ! empty( $maybe_empty ) ) {
foreach ( $post_type_settings['labels'] as $key => $value ) {
if ( 'parent' === $key && array_key_exists( 'parent_item_colon', $post_type_settings['labels'] ) ) {
continue;
}
printf(
'<strong>%s</strong>: %s<br/>',
esc_html( $key ),
esc_html( $value )
);
}
} else {
printf(
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
esc_html__( 'No custom labels to display', 'custom-post-type-ui' )
);
}
?>
</td>
<td>
<p><strong><?php esc_html_e( 'Archives file name examples.', 'custom-post-type-ui' ); ?></strong><br/>
archive-<?php echo esc_html( $post_type ); ?>.php<br/>
archive.php<br/>
index.php
</p>
<p><strong><?php esc_html_e( 'Single Posts file name examples.', 'custom-post-type-ui' ); ?></strong><br/>
single-<?php echo esc_html( $post_type ); ?>-post_slug.php *<br/>
single-<?php echo esc_html( $post_type ); ?>.php<br/>
single.php<br/>
singular.php<br/>
index.php
</p>
<p>
<?php esc_html_e( '*Replace "post_slug" with the slug of the actual post.', 'custom-post-type-ui' ); ?>
</p>
<p>
<?php
printf(
'<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">%s</a>',
esc_html__( 'Template hierarchy Theme Handbook', 'custom-post-type-ui' )
);
?>
</p>
</td>
</tr>
<?php
$counter++;
}
?>
</tbody>
<tfoot>
<tr>
<?php
foreach ( $post_type_table_heads as $head ) {
echo '<th>' . esc_html( $head ) . '</th>';
}
?>
</tr>
</tfoot>
</table>
<?php
/**
* Fires after the listing of registered post type data.
*
* @since 1.3.0
*/
do_action( 'cptui_after_post_type_listing' );
} else {
/**
* Fires when there are no registered post types to list.
*
* @since 1.3.0
*/
do_action( 'cptui_no_post_types_listing' );
}
$taxonomies = cptui_get_taxonomy_data();
echo '<h2 id="taxonomies">' . esc_html__( 'Taxonomies', 'custom-post-type-ui' ) . '</h2>';
if ( ! empty( $taxonomies ) ) {
?>
<p>
<?php
printf(
/* translators: %s: Total count of CPTUI registered taxonomies */
esc_html__( 'Custom Post Type UI registered taxonomies count total: %d', 'custom-post-type-ui' ),
count( $taxonomies )
);
?>
</p>
<?php
$taxonomy_table_heads = [
esc_html__( 'Taxonomy', 'custom-post-type-ui' ),
esc_html__( 'Settings', 'custom-post-type-ui' ),
esc_html__( 'Post Types', 'custom-post-type-ui' ),
esc_html__( 'Labels', 'custom-post-type-ui' ),
esc_html__( 'Template Hierarchy', 'custom-post-type-ui' ),
];
/**
* Fires before the listing of registered taxonomy data.
*
* @since 1.1.0
*/
do_action( 'cptui_before_taxonomy_listing' );
?>
<table class="wp-list-table widefat taxonomy-listing">
<thead>
<tr>
<?php
foreach ( $taxonomy_table_heads as $head ) {
echo '<th>' . esc_html( $head ) . '</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
$counter = 1;
foreach ( $taxonomies as $taxonomy => $taxonomy_settings ) {
$rowclass = ( 0 === $counter % 2 ) ? '' : 'alternate';
$strings = [];
$object_types = [];
foreach ( $taxonomy_settings as $settings_key => $settings_value ) {
if ( 'labels' === $settings_key ) {
continue;
}
if ( is_string( $settings_value ) ) {
$strings[ $settings_key ] = $settings_value;
} else {
if ( 'object_types' === $settings_key ) {
$object_types[ $settings_key ] = $settings_value;
// In case they are not associated from the post type settings.
if ( empty( $object_types['object_types'] ) ) {
$types = get_taxonomy( $taxonomy );
$object_types['object_types'] = $types->object_type;
}
}
}
}
?>
<tr class="<?php echo esc_attr( $rowclass ); ?>">
<?php
$edit_path = 'admin.php?page=cptui_manage_taxonomies&action=edit&cptui_taxonomy=' . $taxonomy;
$taxonomy_link_url = is_network_admin() ? network_admin_url( $edit_path ) : admin_url( $edit_path );
?>
<td>
<?php
printf(
'<a href="%s">%s</a><br/>
<a href="%s">%s</a>',
esc_attr( $taxonomy_link_url ),
sprintf(
/* translators: %s: Taxonomy slug */
esc_html__( 'Edit %1$s (%2$s)', 'custom-post-type-ui' ),
esc_html( $taxonomy_settings['label'] ),
esc_html( $taxonomy )
),
esc_attr( admin_url( 'admin.php?page=cptui_tools&action=get_code#' . $taxonomy ) ),
esc_html__( 'Get code', 'custom-post-type-ui' )
);
?>
</td>
<td>
<?php
foreach ( $strings as $key => $value ) {
printf( '<strong>%s:</strong> ', esc_html( $key ) );
if ( in_array( $value, [ '1', '0' ], true ) ) {
echo esc_html( disp_boolean( $value ) );
} else {
echo ! empty( $value ) ? esc_html( $value ) : '""';
}
echo '<br/>';
}
?>
</td>
<td>
<?php
if ( ! empty( $object_types['object_types'] ) ) {
foreach ( $object_types['object_types'] as $type ) {
echo esc_html( $type ) . '<br/>';
}
}
?>
</td>
<td>
<?php
$maybe_empty = array_filter( $taxonomy_settings['labels'] );
if ( ! empty( $maybe_empty ) ) {
foreach ( $taxonomy_settings['labels'] as $key => $value ) {
printf(
'<strong>%s</strong>: %s<br/>',
esc_html( $key ),
esc_html( $value )
);
}
} else {
printf(
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
esc_html__( 'No custom labels to display', 'custom-post-type-ui' )
);
}
?>
</td>
<td>
<p><strong><?php esc_html_e( 'Archives file name examples.', 'custom-post-type-ui' ); ?></strong><br />
taxonomy-<?php echo esc_html( $taxonomy ); ?>-term_slug.php *<br />
taxonomy-<?php echo esc_html( $taxonomy ); ?>.php<br />
taxonomy.php<br />
archive.php<br />
index.php
</p>
<p>
<?php esc_html_e( '*Replace "term_slug" with the slug of the actual taxonomy term.', 'custom-post-type-ui' ); ?>
</p>
<p>
<?php
printf(
'<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">%s</a>',
esc_html__( 'Template hierarchy Theme Handbook', 'custom-post-type-ui' )
);
?>
</p>
</td>
</tr>
<?php
$counter++;
}
?>
</tbody>
<tfoot>
<tr>
<?php
foreach ( $taxonomy_table_heads as $head ) {
echo '<th>' . esc_html( $head ) . '</th>';
}
?>
</tr>
</tfoot>
</table>
<?php
/**
* Fires after the listing of registered taxonomy data.
*
* @since 1.3.0
*/
do_action( 'cptui_after_taxonomy_listing' );
} else {
/**
* Fires when there are no registered taxonomies to list.
*
* @since 1.3.0
*/
do_action( 'cptui_no_taxonomies_listing' );
}
?>
</div>
<?php
}
/**
* Displays a message for when no post types are registered.
*
* Uses the `cptui_no_post_types_listing` hook.
*
* @since 1.3.0
*
* @internal
*/
function cptui_no_post_types_to_list() {
echo '<p>' . sprintf(
/* translators: 1st %s: Link to manage post types section 2nd %s Link text */
esc_html__( 'No post types registered for display. Visit %s to get started.', 'custom-post-type-ui' ),
sprintf(
'<a href="%s">%s</a>',
esc_attr( admin_url( 'admin.php?page=cptui_manage_post_types' ) ),
esc_html__( 'Add/Edit Post Types', 'custom-post-type-ui' )
)
) . '</p>';
}
add_action( 'cptui_no_post_types_listing', 'cptui_no_post_types_to_list' );
/**
* Displays a message for when no taxonomies are registered.
*
* Uses the `cptui_no_taxonomies_listing` hook.
*
* @since 1.3.0
*
* @internal
*/
function cptui_no_taxonomies_to_list() {
echo '<p>' . sprintf(
/* translators: %s: Link to manage taxonomies section */
esc_html__( 'No taxonomies registered for display. Visit %s to get started.', 'custom-post-type-ui' ),
sprintf(
'<a href="%s">%s</a>',
esc_attr( admin_url( 'admin.php?page=cptui_manage_taxonomies' ) ),
esc_html__( 'Add/Edit Taxonomies', 'custom-post-type-ui' )
)
) . '</p>';
}
add_action( 'cptui_no_taxonomies_listing', 'cptui_no_taxonomies_to_list' );
This diff could not be displayed because it is too large.
<?php
/**
* Custom Post Type UI Support Questions.
*
* @package CPTUI
* @subpackage Support
* @author WebDevStudios
* @since 1.0.0
* @license GPL-2.0+
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Add our cptui.js file, with dependencies on jQuery.
*
* @since 1.0.0
*
* @internal
*/
function cptui_support_enqueue_scripts() {
$current_screen = get_current_screen();
if ( ! is_object( $current_screen ) || 'cpt-ui_page_cptui_support' !== $current_screen->base ) {
return;
}
if ( wp_doing_ajax() ) {
return;
}
wp_enqueue_script( 'cptui' );
wp_enqueue_style( 'cptui-css' );
}
add_action( 'admin_enqueue_scripts', 'cptui_support_enqueue_scripts' );
/**
* Create our settings page output.
*
* @since 1.0.0
*
* @internal
*/
function cptui_support() {
echo '<div class="wrap cptui-support">';
/**
* Fires at the top of the FAQ/Support page.
*
* @since 1.0.0
*/
do_action( 'cptui_main_page_before_faq' ); ?>
<h1><?php esc_html_e( 'Custom Post Type UI Support', 'custom-post-type-ui' ); ?></h1>
<p>
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Please note that %1$s this plugin will not handle display %2$s of registered post types or taxonomies in your current theme. It simply registers them for you. To display your data, check out %3$s. %4$s to see some examples that are available with Custom Post Type UI Extended. If all else fails, visit us on the %5$s', 'custom-post-type-ui' ),
'<strong>',
'</strong>',
'<a href="https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=faq&utm_medium=text&utm_campaign=cptui">' . esc_html__( 'CPTUI Extended', 'custom-post-type-ui' ) . '</a>',
'<a href="https://pluginize.com/cpt-ui-extended-features/?utm_source=faq-layouts&utm_medium=text&utm_campaign=cptui">' . esc_html__( 'View our Layouts page', 'custom-post-type-ui' ) . '</a>',
'<a href="https://www.wordpress.org/support/plugin/custom-post-type-ui/">' . esc_html__( 'Support Forums', 'custom-post-type-ui' ) . '</a>'
);
?>
</p>
<table id="support" class="form-table cptui-table">
<tr>
<td class="outer">
<h2><?php esc_html_e( 'Pluginize', 'custom-post-type-ui' ); ?></h2>
<ol id="questions_pluginize">
<li>
<span tabindex="0" class="question" aria-controls="q1" aria-expanded="false"><?php esc_html_e( 'What is Pluginize?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q1"><?php esc_html_e( 'Pluginize is a marketplace of plugins by WebDevStudios.', 'custom-post-type-ui' ); ?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q2" aria-expanded="false"><?php esc_html_e( 'What does Pluginize offer?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q2"><?php esc_html_e( 'Pluginize offers both free and paid WordPress plugins.', 'custom-post-type-ui' ); ?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q3" aria-expanded="false"><?php esc_html_e( 'Will these ad spots ever show third-party data?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q3"><?php esc_html_e( 'No. These spots are intended for and will only be used for other available WebDevStudios products and services.', 'custom-post-type-ui' ); ?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q4" aria-expanded="false"><?php esc_html_e( 'How can I remove the ads that suddenly started showing up?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q4">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'You can have them automatically removed from display via a purchased copy of %s.', 'custom-post-type-ui' ),
sprintf(
'<a href="%s">%s</a>',
'https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=faq-remove&utm_medium=text&utm_campaign=cptui',
'Custom Post Type UI Extended'
)
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q5" aria-expanded="false"><?php esc_html_e( 'Are these ad spots tracking my personal information in any way?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q5"><?php esc_html_e( 'No, there is no data being sent out from your site with these. The only way anything is tracked is via UTM parameters for WebDevStudios\'s analytics so we can get an idea of where traffic is coming from. Those are only tracked if you actually click on an ad spot.', 'custom-post-type-ui' ); ?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q6" aria-expanded="false"><?php esc_html_e( 'Do I still need Custom Post Type UI if I purchase and install Custom Post Type UI Extended?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q6"><?php esc_html_e( 'Yes you will. The Custom Post Type UI Extended is not a replacement of the free version with added extra features. It acts based on the data made available through Custom Post Type UI', 'custom-post-type-ui' ); ?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q7" aria-expanded="false"><?php esc_html_e( 'Does Custom Post Type UI Extended require multisite?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q7"><?php esc_html_e( 'No it does not. The Shortcode builder is not multisite dependent and will work with either setup.', 'custom-post-type-ui' ); ?>
</div>
</li>
</ol>
</td>
<td class="outer">
<h2><?php esc_html_e( 'General', 'custom-post-type-ui' ); ?></h2>
<ol id="questions_general">
<li>
<span tabindex="0" class="question" aria-controls="q8" aria-expanded="false"><?php esc_html_e( 'I have post types with spaces in their slug and can not successfully delete them. How can I fix that?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q8"><?php esc_html_e( 'Visit the Import/Export page and copy the export code into the import side on the left. Replace the space with an underscore and then click "Import". You should be able to delete the individual post types afterwards.', 'custom-post-type-ui' ); ?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q9" aria-expanded="false"><?php esc_html_e( 'I changed my custom post type name and now I can not get to my posts. How do I get them back?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q9"><?php esc_html_e( 'You can either change the custom post type name back to the original name or try the Post Type Switcher plugin', 'custom-post-type-ui' ); ?>
<a href="https://wordpress.org/plugins/post-type-switcher/" target="_blank" rel="noopener">https://wordpress.org/extend/plugins/post-type-switcher/</a>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q10" aria-expanded="false"><?php esc_html_e( 'I changed my custom post type or taxonomy slug and now I have duplicates shown. How do I remove the duplicate?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q10"><?php esc_html_e( 'Renaming the slug for a post type or taxonomy creates a new entry in our saved option which gets registered as its own post type or taxonomy. Since the settings will be mirrored from the previous slug, you will just need to delete the previous version\'s entry.', 'custom-post-type-ui' ); ?> <a href="https://wordpress.org/plugins/post-type-switcher/" target="_blank" rel="noopener">https://wordpress.org/extend/plugins/post-type-switcher/</a></div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q11" aria-expanded="false"><?php esc_html_e( 'I have added post thumbnail and/or post format support to my post type, but those do not appear when adding a post type post.', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q11"><?php esc_html_e( 'Make sure your theme has post "post-thumbnails" theme support enabled.', 'custom-post-type-ui' ); ?> <a href="https://codex.wordpress.org/Function_Reference/add_theme_support" target="_blank" rel="noopener">https://codex.wordpress.org/Function_Reference/add_theme_support</a></div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q12" aria-expanded="false"><?php esc_html_e( 'Do you have any recommendations for an alternative to Visual Composer?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q12"><?php esc_html_e( 'We recommend using VelocityPage.', 'custom-post-type-ui' ); ?>
<a href="https://velocitypage.com" target="_blank" rel="noopener">https://velocitypage.com</a>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q13" aria-expanded="false"><?php esc_html_e( 'Is there any way to get Custom Post Type UI-registered post types working with Visual Composer Media Grid?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q13"><?php esc_html_e( 'Please see the solution from the following forum support thread.', 'custom-post-type-ui' ); ?>
<a href="https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block?replies=11#post-7111458" target="_blank" rel="noopener">https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block?replies=11#post-7111458</a>
</div>
</li>
</ol>
</td>
</tr>
<tr>
<td class="outer">
<h2><?php esc_html_e( 'Front-end Display', 'custom-post-type-ui' ); ?></h2>
<ol id="questions_front">
<li>
<span tabindex="0" class="question" aria-controls="q14" aria-expanded="false"><?php esc_html_e( 'What template files should I edit to alter my post type display?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q14">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Please visit the %1$sTemplate Hierarchy%2$s page on the WordPress codex for details about available templates.', 'custom-post-type-ui' ),
'<a href="https://codex.wordpress.org/Template_Hierarchy" target="_blank" rel="noopener">',
'</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q15" aria-expanded="false"><?php esc_html_e( 'How do I display my custom post type on my site?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q15">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'We encourage checking out %1$s for easily displaying post type content wherever you can utilize a shortcode. If you prefer to handle on your own, you will need to utilize the %2$s class to handle display in custom locations. If you have set the post type to have archives, the archive url should be something like "http://www.mysite.com/post-type-slug"', 'custom-post-type-ui' ),
sprintf(
'<a href="%s">%s</a>',
'https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=faq&utm_medium=text&utm_campaign=cptui',
'Custom Post Type UI Extended'
),
'<a href="https://codex.wordpress.org/Class_Reference/WP_Query" target="_blank" rel="noopener">WP_Query</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q16" aria-expanded="false"><?php esc_html_e( 'I have added categories and tags to my custom post type, but they do not appear in the archives.', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q16">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'You will need to add your newly created post type to the types that the category and tag archives query for. You can see a tutorial on how to do that at %s', 'custom-post-type-ui' ),
'<a href="http://docs.pluginize.com/article/17-post-types-in-category-tag-archives" target="_blank" rel="noopener">http://docs.pluginize.com/article/17-post-types-in-category-tag-archives</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q17" aria-expanded="false"><?php esc_html_e( 'How do I add custom post type support for custom templates selection like pages have?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q17">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Please visit the %1$sPost Type Templates in 4.7%2$s post on the Make WordPress Core blog for details about setting templates for multiple post types.', 'custom-post-type-ui' ),
'<a href="https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/" target="_blank" rel="noopener">',
'</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q18" aria-expanded="false"><?php esc_html_e( 'Why are my post types not showing in taxonomy term archives?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q18">
<?php
esc_html_e( 'If you have set "exclude from search" to True for the pot type, this would be why. If you need the post types in the archives, but still want to exclude them from search, it is recommended to use the "pre_get_posts" hook to unset the post type from considered types.', 'custom-post-type-ui' );
?>
</div>
</li>
</ol>
</td>
<td class="outer">
<h2><?php esc_html_e( 'Advanced', 'custom-post-type-ui' ); ?></h2>
<ol id="questions_advanced">
<li>
<span tabindex="0" class="question" aria-controls="q19" aria-expanded="false"><?php esc_html_e( 'How do I add custom metaboxes to my post type?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q19">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'We recommend checking out %s, the latest iteration of "CMB2". Both are supported by WebDevStudios.', 'custom-post-type-ui' ),
'<a href="https://wordpress.org/plugins/cmb2/" target="_blank" rel="noopener">CMB2</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q20" aria-expanded="false"><?php esc_html_e( 'How do I add a newly registered taxonomy to a post type that already exists?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q20">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Check out the %s function for documentation and usage examples.', 'custom-post-type-ui' ),
'<a href="https://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type" target="_blank" rel="noopener">register_taxonomy_for_object_type()</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q21" aria-expanded="false"><?php esc_html_e( 'Post relationships?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q21">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%1$s has an excellent %2$spost%3$s introducing users to the %4$sPosts 2 Posts%5$s plugin that should be a good start.', 'custom-post-type-ui' ),
'Pippin Williamson',
'<a href="https://pippinsplugins.com/introduction-posts-2-posts-plugin/" target="_blank" rel="noopener">',
'</a>',
'<a href="https://wordpress.org/plugins/posts-to-posts/" target="_blank" rel="noopener">',
'</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q22" aria-expanded="false"><?php esc_html_e( 'Is there any function reference list?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q22">
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%s has compiled a nice list of functions used by our plugin. Note not all will be useful as they are attached to hooks.', 'custom-post-type-ui' ),
'<a href="http://hookr.io/plugins/custom-post-type-ui/" target="_blank" rel="noopener">Hookr.io</a>'
);
?>
</div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q23" aria-expanded="false"><?php esc_html_e( 'How do I filter the "enter title here" text in the post editor screen?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q23"><p><?php esc_html_e( 'Change text inside the post/page editor title field. Should be able to adapt as necessary.', 'custom-post-type-ui' ); ?></p>
<pre><code>function my_custom_title_text( $title ){
global $post;
if ( 'ENTER POST TYPE SLUG HERE' == $post->post_type )
return 'NEW CUSTOM TEXT HERE';
}
}
add_filter( 'enter_title_here', 'my_custom_title_text' );
</code></pre></div>
</li>
<li>
<span tabindex="0" class="question" aria-controls="q25" aria-expanded="false"><?php esc_html_e( 'Any help with customizing capabilities?', 'custom-post-type-ui' ); ?></span>
<div class="answer" id="q25">
<p>
<?php
printf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'We recommend %s for some extended customization and addition of extra fields regarding roles and capabilities.', 'custom-post-type-ui' ),
'<a href="https://github.com/tw2113/custom-post-type-ui-capabilities" target="_blank" rel="noopener">Custom Post Type UI Capabilities on GitHub</a>'
);
?>
</p>
</div>
</li>
</ol>
</td>
<td class="outer">
&nbsp;
<?php
/**
* Fires in the last table cell of the FAQ list.
*
* @since 1.0.0
*/
do_action( 'cptui_main_page_custom_questions' );
?>
</td>
</tr>
</table>
<?php
/**
* Fires at the bottom of the FAQ/Support page.
*
* @since 1.0.0
*/
do_action( 'cptui_main_page_after_faq' );
echo '</div>';
}
<?php
/**
* Custom Post Type UI Taxonomy Settings.
*
* @package CPTUI
* @subpackage Taxonomies
* @author WebDevStudios
* @since 1.0.0
* @license GPL-2.0+
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Add our cptui.js file, with dependencies on jQuery and jQuery UI.
*
* @since 1.0.0
*
* @internal
*/
function cptui_taxonomies_enqueue_scripts() {
$current_screen = get_current_screen();
if ( ! is_object( $current_screen ) || 'cpt-ui_page_cptui_manage_taxonomies' !== $current_screen->base ) {
return;
}
if ( wp_doing_ajax() ) {
return;
}
wp_enqueue_script( 'cptui' );
wp_enqueue_style( 'cptui-css' );
$core = get_taxonomies(
[
'_builtin' => true,
]
);
$public = get_taxonomies(
[
'_builtin' => false,
'public' => true,
]
);
$private = get_taxonomies(
[
'_builtin' => false,
'public' => false,
]
);
$registered_taxonomies = array_merge( $core, $public, $private );
wp_localize_script(
'cptui',
'cptui_tax_data',
[
'confirm' => esc_html__( 'Are you sure you want to delete this? Deleting will NOT remove created content.', 'custom-post-type-ui' ),
'no_associated_type' => esc_html__( 'Please select a post type to associate with.', 'custom-post-type-ui' ),
'existing_taxonomies' => $registered_taxonomies,
]
);
}
add_action( 'admin_enqueue_scripts', 'cptui_taxonomies_enqueue_scripts' );
/**
* Register our tabs for the Taxonomy screen.
*
* @since 1.3.0
*
* @internal
*
* @param array $tabs Array of tabs to display. Optional.
* @param string $current_page Current page being shown. Optional. Default empty string.
* @return array Amended array of tabs to show.
*/
function cptui_taxonomy_tabs( $tabs = [], $current_page = '' ) {
if ( 'taxonomies' === $current_page ) {
$taxonomies = cptui_get_taxonomy_data();
$classes = [ 'nav-tab' ];
$tabs['page_title'] = get_admin_page_title();
$tabs['tabs'] = [];
$tabs['tabs']['add'] = [ // Start out with our basic "Add new" tab.
'text' => esc_html__( 'Add New Taxonomy', 'custom-post-type-ui' ),
'classes' => $classes,
'url' => cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ),
'aria-selected' => 'false',
];
$action = cptui_get_current_action();
if ( empty( $action ) ) {
$tabs['tabs']['add']['classes'][] = 'nav-tab-active';
$tabs['tabs']['add']['aria-selected'] = 'true';
}
if ( ! empty( $taxonomies ) ) {
if ( ! empty( $action ) ) {
$classes[] = 'nav-tab-active';
}
$tabs['tabs']['edit'] = [
'text' => esc_html__( 'Edit Taxonomies', 'custom-post-type-ui' ),
'classes' => $classes,
'url' => esc_url( add_query_arg( [ 'action' => 'edit' ], cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ) ) ),
'aria-selected' => ! empty( $action ) ? 'true' : 'false',
];
$tabs['tabs']['view'] = [
'text' => esc_html__( 'View Taxonomies', 'custom-post-type-ui' ),
'classes' => [ 'nav-tab' ], // Prevent notices.
'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_listings#taxonomies' ) ),
'aria-selected' => 'false',
];
$tabs['tabs']['export'] = [
'text' => esc_html__( 'Import/Export Taxonomies', 'custom-post-type-ui' ),
'classes' => [ 'nav-tab' ], // Prevent notices.
'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_tools&action=taxonomies' ) ),
'aria-selected' => 'false',
];
}
}
return $tabs;
}
add_filter( 'cptui_get_tabs', 'cptui_taxonomy_tabs', 10, 2 );
/**
* Create our settings page output.
*
* @since 1.0.0
*
* @internal
*/
function cptui_manage_taxonomies() {
$tab = ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] ) ? 'edit' : 'new'; // phpcs:ignore.
$tab_class = 'cptui-' . $tab;
$current = null;
?>
<div class="wrap <?php echo esc_attr( $tab_class ); ?>">
<?php
/**
* Fires right inside the wrap div for the taxonomy editor screen.
*
* @since 1.3.0
*/
do_action( 'cptui_inside_taxonomy_wrap' );
/**
* Filters whether or not a taxonomy was deleted.
*
* @since 1.4.0
*
* @param bool $value Whether or not taxonomy deleted. Default false.
*/
$taxonomy_deleted = apply_filters( 'cptui_taxonomy_deleted', false );
// Create our tabs.
cptui_settings_tab_menu( 'taxonomies' );
/**
* Fires below the output for the tab menu on the taxonomy add/edit screen.
*
* @since 1.3.0
*/
do_action( 'cptui_below_taxonomy_tab_menu' );
if ( 'edit' === $tab ) {
$taxonomies = cptui_get_taxonomy_data();
$selected_taxonomy = cptui_get_current_taxonomy( $taxonomy_deleted );
if ( $selected_taxonomy && array_key_exists( $selected_taxonomy, $taxonomies ) ) {
$current = $taxonomies[ $selected_taxonomy ];
}
}
$ui = new cptui_admin_ui();
// Will only be set if we're already on the edit screen.
if ( ! empty( $taxonomies ) ) {
?>
<form id="cptui_select_taxonomy" method="post" action="<?php echo esc_url( cptui_get_post_form_action( $ui ) ); ?>">
<label for="taxonomy"><?php esc_html_e( 'Select: ', 'custom-post-type-ui' ); ?></label>
<?php
cptui_taxonomies_dropdown( $taxonomies );
wp_nonce_field( 'cptui_select_taxonomy_nonce_action', 'cptui_select_taxonomy_nonce_field' );
/**
* Filters the text value to use on the select taxonomy button.
*
* @since 1.0.0
*
* @param string $value Text to use for the button.
*/
?>
<input type="submit" class="button-secondary" id="cptui_select_taxonomy_submit" name="cptui_select_taxonomy_submit" value="<?php echo esc_attr( apply_filters( 'cptui_taxonomy_submit_select', esc_attr__( 'Select', 'custom-post-type-ui' ) ) ); ?>" />
</form>
<?php
/**
* Fires below the taxonomy select input.
*
* @since 1.1.0
*
* @param string $value Current taxonomy selected.
*/
do_action( 'cptui_below_taxonomy_select', $current['name'] );
}
?>
<form class="taxonomiesui" method="post" action="<?php echo esc_url( cptui_get_post_form_action( $ui ) ); ?>">
<div class="postbox-container">
<div id="poststuff">
<div class="cptui-section postbox">
<div class="postbox-header">
<h2 class="hndle ui-sortable-handle">
<span><?php esc_html_e( 'Basic settings', 'custom-post-type-ui' ); ?></span>
</h2>
<div class="handle-actions hide-if-no-js">
<button type="button" class="handlediv" aria-expanded="true">
<span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Basic settings', 'custom-post-type-ui' ); ?></span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</div>
</div>
<div class="inside">
<div class="main">
<table class="form-table cptui-table">
<?php
echo $ui->get_tr_start() . $ui->get_th_start(); // phpcs:ignore.
echo $ui->get_label( 'name', esc_html__( 'Taxonomy Slug', 'custom-post-type-ui' ) ) . $ui->get_required_span(); // phpcs:ignore.
if ( 'edit' === $tab ) {
echo '<p id="slugchanged" class="hidemessage">' . esc_html__( 'Slug has changed', 'custom-post-type-ui' ) . '<span class="dashicons dashicons-warning"></span></p>';
}
echo '<p id="slugexists" class="hidemessage">' . esc_html__( 'Slug already exists', 'custom-post-type-ui' ) . '<span class="dashicons dashicons-warning"></span></p>';
echo $ui->get_th_end() . $ui->get_td_start(); // phpcs:ignore.
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'name',
'textvalue' => isset( $current['name'] ) ? esc_attr( $current['name'] ) : '', // phpcs:ignore.
'maxlength' => '32',
'helptext' => esc_attr__( 'The taxonomy name/slug. Used for various queries for taxonomy content.', 'custom-post-type-ui' ),
'required' => true,
'placeholder' => false,
'wrap' => false,
]
);
echo '<p class="cptui-slug-details">';
esc_html_e( 'Slugs should only contain alphanumeric, latin characters. Underscores should be used in place of spaces. Set "Custom Rewrite Slug" field to make slug use dashes for URLs.', 'custom-post-type-ui' );
echo '</p>';
if ( 'edit' === $tab ) {
echo '<p>';
esc_html_e( 'DO NOT EDIT the taxonomy slug unless also planning to migrate terms. Changing the slug registers a new taxonomy entry.', 'custom-post-type-ui' );
echo '</p>';
echo '<div class="cptui-spacer">';
echo $ui->get_check_input( // phpcs:ignore.
[
'checkvalue' => 'update_taxonomy',
'checked' => 'false',
'name' => 'update_taxonomy',
'namearray' => 'update_taxonomy',
'labeltext' => esc_html__( 'Migrate terms to newly renamed taxonomy?', 'custom-post-type-ui' ),
'helptext' => '',
'default' => false,
'wrap' => false,
]
);
echo '</div>';
}
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'label',
'textvalue' => isset( $current['label'] ) ? esc_attr( $current['label'] ) : '', // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. Actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Plural Label', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Used for the taxonomy admin menu item.', 'custom-post-type-ui' ),
'required' => true,
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'singular_label',
'textvalue' => isset( $current['singular_label'] ) ? esc_attr( $current['singular_label'] ) : '', // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. Actor)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Singular Label', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Used when a singular label is needed.', 'custom-post-type-ui' ),
'required' => true,
]
);
echo $ui->get_td_end() . $ui->get_tr_end(); // phpcs:ignore.
$link_text = ( 'new' === $tab ) ?
esc_html__( 'Populate additional labels based on chosen labels', 'custom-post-type-ui' ) :
esc_html__( 'Populate missing labels based on chosen labels', 'custom-post-type-ui' );
echo $ui->get_tr_end(); // phpcs:ignore.
echo $ui->get_th_start() . esc_html__( 'Auto-populate labels', 'custom-post-type-ui' ) . $ui->get_th_end(); // phpcs:ignore.
echo $ui->get_td_start(); // phpcs:ignore.
?>
<a href="#" id="auto-populate"><?php echo esc_html( $link_text ); ?></a> |
<a href="#" id="auto-clear"><?php esc_html_e( 'Clear labels', 'custom-post-type-ui' ); ?></a>
<?php
echo $ui->get_td_end() . $ui->get_tr_end(); // phpcs:ignore.
echo $ui->get_tr_start() . $ui->get_th_start() . esc_html__( 'Attach to Post Type', 'custom-post-type-ui' ) . $ui->get_required_span(); // phpcs:ignore.
echo $ui->get_p( esc_html__( 'Add support for available registered post types. At least one is required. Only public post types listed by default.', 'custom-post-type-ui' ) ); // phpcs:ignore.
echo $ui->get_th_end() . $ui->get_td_start() . $ui->get_fieldset_start(); // phpcs:ignore.
echo $ui->get_legend_start() . esc_html__( 'Post type options', 'custom-post-type-ui' ) . $ui->get_legend_end(); // phpcs:ignore.
/**
* Filters the arguments for post types to list for taxonomy association.
*
* @since 1.0.0
*
* @param array $value Array of default arguments.
*/
$args = apply_filters( 'cptui_attach_post_types_to_taxonomy', [ 'public' => true ] );
// If they don't return an array, fall back to the original default. Don't need to check for empty, because empty array is default for $args param in get_post_types anyway.
if ( ! is_array( $args ) ) {
$args = [ 'public' => true ];
}
$output = 'objects'; // Or objects.
/**
* Filters the results returned to display for available post types for taxonomy.
*
* @since 1.3.0
*
* @param array $value Array of post type objects.
* @param array $args Array of arguments for the post type query.
* @param string $output The output type we want for the results.
*/
$post_types = apply_filters( 'cptui_get_post_types_for_taxonomies', get_post_types( $args, $output ), $args, $output );
foreach ( $post_types as $post_type ) {
$core_label = in_array(
$post_type->name,
[
'post',
'page',
'attachment',
],
true
) ? esc_html__( '(WP Core)', 'custom-post-type-ui' ) : '';
echo $ui->get_check_input( // phpcs:ignore.
[
'checkvalue' => $post_type->name,
'checked' => ( ! empty( $current['object_types'] ) && is_array( $current['object_types'] ) && in_array( $post_type->name, $current['object_types'], true ) ) ? 'true' : 'false', // phpcs:ignore.
'name' => esc_attr( $post_type->name ),
'namearray' => 'cpt_post_types',
'textvalue' => esc_attr( $post_type->name ),
'labeltext' => "{$post_type->label} {$core_label}", // phpcs:ignore.
'wrap' => false,
]
);
}
echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end(); // phpcs:ignore.
?>
</table>
<p class="submit">
<?php
wp_nonce_field( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) { // phpcs:ignore.
/**
* Filters the text value to use on the button when editing.
*
* @since 1.0.0
*
* @param string $value Text to use for the button.
*/
?>
<input type="submit" class="button-primary cptui-taxonomy-submit" name="cpt_submit" value="<?php echo esc_attr( apply_filters( 'cptui_taxonomy_submit_edit', esc_attr__( 'Save Taxonomy', 'custom-post-type-ui' ) ) ); ?>" />
<?php
/**
* Filters the text value to use on the button when deleting.
*
* @since 1.0.0
*
* @param string $value Text to use for the button.
*/
?>
<input type="submit" class="button-secondary cptui-delete-top" name="cpt_delete" id="cpt_submit_delete" value="<?php echo esc_attr( apply_filters( 'cptui_taxonomy_submit_delete', esc_attr__( 'Delete Taxonomy', 'custom-post-type-ui' ) ) ); ?>" />
<?php } else { ?>
<?php
/**
* Filters the text value to use on the button when adding.
*
* @since 1.0.0
*
* @param string $value Text to use for the button.
*/
?>
<input type="submit" class="button-primary cptui-taxonomy-submit" name="cpt_submit" value="<?php echo esc_attr( apply_filters( 'cptui_taxonomy_submit_add', esc_attr__( 'Add Taxonomy', 'custom-post-type-ui' ) ) ); ?>" />
<?php } ?>
<?php if ( ! empty( $current ) ) { ?>
<input type="hidden" name="tax_original" id="tax_original" value="<?php echo esc_attr( $current['name'] ); ?>" />
<?php
}
// Used to check and see if we should prevent duplicate slugs.
?>
<input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo esc_attr( $tab ); ?>" />
</p>
</div>
</div>
</div>
<div class="cptui-section cptui-labels postbox">
<div class="postbox-header">
<h2 class="hndle ui-sortable-handle">
<span><?php esc_html_e( 'Additional labels', 'custom-post-type-ui' ); ?></span>
</h2>
<div class="handle-actions hide-if-no-js">
<button type="button" class="handlediv" aria-expanded="true">
<span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Additional labels', 'custom-post-type-ui' ); ?></span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</div>
</div>
<div class="inside">
<div class="main">
<table class="form-table cptui-table">
<?php
if ( isset( $current['description'] ) ) {
$current['description'] = stripslashes_deep( $current['description'] );
}
echo $ui->get_textarea_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'description',
'rows' => '4',
'cols' => '40',
'textvalue' => isset( $current['description'] ) ? esc_textarea( $current['description'] ) : '', // phpcs:ignore.
'labeltext' => esc_html__( 'Description', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Describe what your taxonomy is used for.', 'custom-post-type-ui' ),
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'menu_name',
'textvalue' => isset( $current['labels']['menu_name'] ) ? esc_attr( $current['labels']['menu_name'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Menu Name', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom admin menu name for your taxonomy.', 'custom-post-type-ui' ),
'data' => [
'label' => 'item', // Not localizing because it's isolated.
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'all_items',
'textvalue' => isset( $current['labels']['all_items'] ) ? esc_attr( $current['labels']['all_items'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. All Actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'All Items', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Used as tab text when showing all terms for hierarchical taxonomy while editing post.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'All %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'edit_item',
'textvalue' => isset( $current['labels']['edit_item'] ) ? esc_attr( $current['labels']['edit_item'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Edit Actor)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Edit Item', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Used at the top of the term editor screen for an existing taxonomy term.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Edit %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'view_item',
'textvalue' => isset( $current['labels']['view_item'] ) ? esc_attr( $current['labels']['view_item'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. View Actor)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'View Item', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Used in the admin bar when viewing editor screen for an existing taxonomy term.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'View %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'update_item',
'textvalue' => isset( $current['labels']['update_item'] ) ? esc_attr( $current['labels']['update_item'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Update Actor Name)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Update Item Name', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Update %s name', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'add_new_item',
'textvalue' => isset( $current['labels']['add_new_item'] ) ? esc_attr( $current['labels']['add_new_item'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Add New Actor)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Add New Item', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Used at the top of the term editor screen and button text for a new taxonomy term.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Add new %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'new_item_name',
'textvalue' => isset( $current['labels']['new_item_name'] ) ? esc_attr( $current['labels']['new_item_name'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. New Actor Name)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'New Item Name', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'New %s name', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'parent_item',
'textvalue' => isset( $current['labels']['parent_item'] ) ? esc_attr( $current['labels']['parent_item'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Parent Actor)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Parent Item', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Parent %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'parent_item_colon',
'textvalue' => isset( $current['labels']['parent_item_colon'] ) ? esc_attr( $current['labels']['parent_item_colon'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Parent Actor:)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Parent Item Colon', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Parent %s:', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'search_items',
'textvalue' => isset( $current['labels']['search_items'] ) ? esc_attr( $current['labels']['search_items'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Search Actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Search Items', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Search %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'popular_items',
'textvalue' => isset( $current['labels']['popular_items'] ) ? esc_attr( $current['labels']['popular_items'] ) : null, // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Popular Actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Popular Items', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Popular %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'separate_items_with_commas',
'textvalue' => isset( $current['labels']['separate_items_with_commas'] ) ? esc_attr( $current['labels']['separate_items_with_commas'] ) : null, // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Separate Actors with commas)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Separate Items with Commas', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Separate %s with commas', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'add_or_remove_items',
'textvalue' => isset( $current['labels']['add_or_remove_items'] ) ? esc_attr( $current['labels']['add_or_remove_items'] ) : null, // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Add or remove Actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Add or Remove Items', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Add or remove %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'choose_from_most_used',
'textvalue' => isset( $current['labels']['choose_from_most_used'] ) ? esc_attr( $current['labels']['choose_from_most_used'] ) : null, // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. Choose from the most used Actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Choose From Most Used', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'The text displayed via clicking ‘Choose from the most used items’ in the taxonomy meta box when no items are available.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Choose from the most used %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'not_found',
'textvalue' => isset( $current['labels']['not_found'] ) ? esc_attr( $current['labels']['not_found'] ) : null, // phpcs:ignore.
'aftertext' => esc_attr__( '(e.g. No Actors found)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Not found', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Used when indicating that there are no terms in the given taxonomy within the meta box and taxonomy list table.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'No %s found', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'no_terms',
'textvalue' => isset( $current['labels']['no_terms'] ) ? esc_attr( $current['labels']['no_terms'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. No actors)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'No terms', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Used when indicating that there are no terms in the given taxonomy associated with an object.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'No %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'items_list_navigation',
'textvalue' => isset( $current['labels']['items_list_navigation'] ) ? esc_attr( $current['labels']['items_list_navigation'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. Actors list navigation)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Items List Navigation', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Screen reader text for the pagination heading on the term listing screen.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( '%s list navigation', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'items_list',
'textvalue' => isset( $current['labels']['items_list'] ) ? esc_attr( $current['labels']['items_list'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. Actors list)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Items List', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Screen reader text for the items list heading on the term listing screen.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( '%s list', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'back_to_items',
'textvalue' => isset( $current['labels']['back_to_items'] ) ? esc_attr( $current['labels']['back_to_items'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. &larr; Back to actors', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Back to Items', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'The text displayed after a term has been updated for a link back to main index.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Back to %s', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'name_field_description',
'textvalue' => isset( $current['labels']['name_field_description'] ) ? esc_attr( $current['labels']['name_field_description'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. "The name is how it appears on your site."', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Term Name Field Description', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Description for the Name field on Edit Tags screen.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'The name is how it appears on your site.', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'parent_field_description',
'textvalue' => isset( $current['labels']['parent_field_description'] ) ? esc_attr( $current['labels']['parent_field_description'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. "Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band."', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Term Parent Field Description', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Description for the Parent field on Edit Tags screen.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band.', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'slug_field_description',
'textvalue' => isset( $current['labels']['slug_field_description'] ) ? esc_attr( $current['labels']['slug_field_description'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. "The « slug » is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens."', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Term Slug Field Description', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Description for the Slug field on Edit Tags screen. ', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'The "slug" is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'singular',
],
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_tax_labels',
'name' => 'desc_field_description',
'textvalue' => isset( $current['labels']['desc_field_description'] ) ? esc_attr( $current['labels']['desc_field_description'] ) : null, // phpcs:ignore.
'aftertext' => esc_html__( '(e.g. "The description is not prominent by default; however, some themes may show it."', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Term Description Field Description', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Description for the Description field on Edit Tags screen.', 'custom-post-type-ui' ),
'data' => [
/* translators: Used for autofill */
'label' => sprintf( esc_attr__( 'The description is not prominent by default; however, some themes may show it.', 'custom-post-type-ui' ), 'item' ),
'plurality' => 'plural',
],
]
);
?>
</table>
</div>
</div>
</div>
<div class="cptui-section cptui-settings postbox">
<div class="postbox-header">
<h2 class="hndle ui-sortable-handle">
<span><?php esc_html_e( 'Settings', 'custom-post-type-ui' ); ?></span>
</h2>
<div class="handle-actions hide-if-no-js">
<button type="button" class="handlediv" aria-expanded="true">
<span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Settings', 'custom-post-type-ui' ); ?></span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</div>
</div>
<div class="inside">
<div class="main">
<table class="form-table cptui-table">
<?php
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['public'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['public'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'public',
'labeltext' => esc_html__( 'Public', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: true) Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['publicly_queryable'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['publicly_queryable'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'publicly_queryable',
'labeltext' => esc_html__( 'Public Queryable', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: value of "public" setting) Whether or not the taxonomy should be publicly queryable.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
'default' => 'true',
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['hierarchical'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['hierarchical'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'hierarchical',
'labeltext' => esc_html__( 'Hierarchical', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: false) Whether the taxonomy can have parent-child relationships. "True" gives checkboxes, "False" gives text input.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['show_ui'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['show_ui'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'show_ui',
'labeltext' => esc_html__( 'Show UI', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: true) Whether to generate a default UI for managing this custom taxonomy.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['show_in_menu'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['show_in_menu'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'show_in_menu',
'labeltext' => esc_html__( 'Show in menu', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: value of show_ui) Whether to show the taxonomy in the admin menu.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = ( isset( $current ) && ! empty( $current['show_in_nav_menus'] ) ) ? disp_boolean( $current['show_in_nav_menus'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['show_in_nav_menus'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'show_in_nav_menus',
'labeltext' => esc_html__( 'Show in nav menus', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: value of public) Whether to make the taxonomy available for selection in navigation menus.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['query_var'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['query_var'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'query_var',
'labeltext' => esc_html__( 'Query Var', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: true) Sets the query_var key for this taxonomy.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'query_var_slug',
'textvalue' => isset( $current['query_var_slug'] ) ? esc_attr( $current['query_var_slug'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(default: taxonomy slug). Query var needs to be true to use.', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Custom Query Var String', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Sets a custom query_var slug for this taxonomy.', 'custom-post-type-ui' ),
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['rewrite'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['rewrite'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'rewrite',
'labeltext' => esc_html__( 'Rewrite', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: true) Whether or not WordPress should use rewrites for this taxonomy.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'rewrite_slug',
'textvalue' => isset( $current['rewrite_slug'] ) ? esc_attr( $current['rewrite_slug'] ) : '', // phpcs:ignore.
'aftertext' => esc_attr__( '(default: taxonomy name)', 'custom-post-type-ui' ),
'labeltext' => esc_html__( 'Custom Rewrite Slug', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Custom taxonomy rewrite slug.', 'custom-post-type-ui' ),
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['rewrite_withfront'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['rewrite_withfront'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'rewrite_withfront',
'labeltext' => esc_html__( 'Rewrite With Front', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: true) Should the permastruct be prepended with the front base.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
'default' => 'false',
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['rewrite_hierarchical'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['rewrite_hierarchical'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'rewrite_hierarchical',
'labeltext' => esc_html__( 'Rewrite Hierarchical', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: false) Should the permastruct allow hierarchical urls.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
'default' => 'true',
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['show_admin_column'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['show_admin_column'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'show_admin_column',
'labeltext' => esc_html__( 'Show Admin Column', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: false) Whether to allow automatic creation of taxonomy columns on associated post-types.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
'default' => 'true',
],
],
];
$selected = isset( $current ) ? disp_boolean( $current['show_in_rest'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['show_in_rest'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'show_in_rest',
'labeltext' => esc_html__( 'Show in REST API', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether to show this taxonomy data in the WP REST API.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'rest_base',
'labeltext' => esc_html__( 'REST API base slug', 'custom-post-type-ui' ),
'helptext' => esc_attr__( 'Slug to use in REST API URLs.', 'custom-post-type-ui' ),
'textvalue' => isset( $current['rest_base'] ) ? esc_attr( $current['rest_base'] ) : '', // phpcs:ignore.
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'rest_controller_class',
'labeltext' => esc_html__( 'REST API controller class', 'custom-post-type-ui' ),
'aftertext' => esc_attr__( '(default: WP_REST_Terms_Controller) Custom controller to use instead of WP_REST_Terms_Controller.', 'custom-post-type-ui' ),
'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '', // phpcs:ignore.
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'rest_namespace',
'labeltext' => esc_html__( 'REST API namespace', 'custom-post-type-ui' ),
'aftertext' => esc_attr__( '(default: wp/v2) To change the namespace URL of REST API route.', 'custom-post-type-ui' ),
'textvalue' => isset( $current['rest_namespace'] ) ? esc_attr( $current['rest_namespace'] ) : '', // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
'default' => 'false',
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
],
],
];
$selected = ( isset( $current ) && ! empty( $current['show_tagcloud'] ) ) ? disp_boolean( $current['show_tagcloud'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['show_tagcloud'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'show_tagcloud',
'labeltext' => esc_html__( 'Show in tag cloud.', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: inherited from "show_ui") Whether to list the taxonomy in the Tag Cloud Widget controls.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
'default' => 'false',
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
],
],
];
$selected = ( isset( $current ) && ! empty( $current['show_in_quick_edit'] ) ) ? disp_boolean( $current['show_in_quick_edit'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['show_in_quick_edit'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'show_in_quick_edit',
'labeltext' => esc_html__( 'Show in quick/bulk edit panel.', 'custom-post-type-ui' ),
'aftertext' => esc_html__( '(default: false) Whether to show the taxonomy in the quick/bulk edit panel.', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
$select = [
'options' => [
[
'attr' => '0',
'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
'default' => 'false',
],
[
'attr' => '1',
'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
],
],
];
$selected = ( isset( $current ) && ! empty( $current['sort'] ) ) ? disp_boolean( $current['sort'] ) : '';
$select['selected'] = ! empty( $selected ) ? $current['sort'] : '';
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'sort',
'labeltext' => esc_html__( 'Sort', 'custom-post-type-ui' ),
'aftertext' => esc_html__( 'Whether terms in this taxonomy should be sorted in the order they are provided to wp_set_object_terms()', 'custom-post-type-ui' ),
'selections' => $select, // phpcs:ignore.
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'meta_box_cb',
'textvalue' => isset( $current['meta_box_cb'] ) ? esc_attr( $current['meta_box_cb'] ) : '', // phpcs:ignore.
'labeltext' => esc_html__( 'Metabox callback', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Sets a callback function name for the meta box display. Hierarchical default: post_categories_meta_box, non-hierarchical default: post_tags_meta_box. To remove the metabox completely, use "false".', 'custom-post-type-ui' ),
]
);
echo $ui->get_text_input( // phpcs:ignore.
[
'namearray' => 'cpt_custom_tax',
'name' => 'default_term',
'textvalue' => isset( $current['default_term'] ) ? esc_attr( $current['default_term'] ) : '', // phpcs:ignore.
'labeltext' => esc_html__( 'Default Term', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Set a default term for the taxonomy. Able to set a name, slug, and description. Only a name is required if setting a default, others are optional. Set values in the following order, separated by comma. Example: name, slug, description', 'custom-post-type-ui' ),
]
);
?>
</table>
</div>
</div>
</div>
<?php
/**
* Fires after the default fieldsets on the taxonomy screen.
*
* @since 1.3.0
*
* @param cptui_admin_ui $ui Admin UI instance.
*/
do_action( 'cptui_taxonomy_after_fieldsets', $ui );
?>
<p class="submit">
<?php
wp_nonce_field( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
/**
* Filters the text value to use on the button when editing.
*
* @since 1.0.0
*
* @param string $value Text to use for the button.
*/
?>
<input type="submit" class="button-primary cptui-taxonomy-submit" name="cpt_submit" value="<?php echo esc_attr( apply_filters( 'cptui_taxonomy_submit_edit', esc_attr__( 'Save Taxonomy', 'custom-post-type-ui' ) ) ); ?>" />
<?php
/**
* Filters the text value to use on the button when deleting.
*
* @since 1.0.0
*
* @param string $value Text to use for the button.
*/
?>
<input type="submit" class="button-secondary cptui-delete-bottom" name="cpt_delete" id="cpt_submit_delete" value="<?php echo esc_attr( apply_filters( 'cptui_taxonomy_submit_delete', esc_attr__( 'Delete Taxonomy', 'custom-post-type-ui' ) ) ); ?>" />
<?php } else { ?>
<?php
/**
* Filters the text value to use on the button when adding.
*
* @since 1.0.0
*
* @param string $value Text to use for the button.
*/
?>
<input type="submit" class="button-primary cptui-taxonomy-submit" name="cpt_submit" value="<?php echo esc_attr( apply_filters( 'cptui_taxonomy_submit_add', esc_attr__( 'Add Taxonomy', 'custom-post-type-ui' ) ) ); ?>" />
<?php } ?>
<?php if ( ! empty( $current ) ) { ?>
<input type="hidden" name="tax_original" id="tax_original" value="<?php echo esc_attr( $current['name'] ); ?>" />
<?php
}
// Used to check and see if we should prevent duplicate slugs.
?>
<input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo esc_attr( $tab ); ?>" />
</p>
</div>
</div>
</form>
</div><!-- End .wrap -->
<?php
}
/**
* Construct a dropdown of our taxonomies so users can select which to edit.
*
* @since 1.0.0
*
* @param array $taxonomies Array of taxonomies that are registered. Optional.
*/
function cptui_taxonomies_dropdown( $taxonomies = [] ) {
$ui = new cptui_admin_ui();
if ( ! empty( $taxonomies ) ) {
$select = [];
$select['options'] = [];
foreach ( $taxonomies as $tax ) {
$text = ! empty( $tax['label'] ) ? esc_html( $tax['label'] ) : esc_html( $tax['name'] );
$select['options'][] = [
'attr' => $tax['name'],
'text' => $text,
];
}
$current = cptui_get_current_taxonomy();
$select['selected'] = $current;
/**
* Filters the taxonomy dropdown options before rendering.
*
* @since 1.6.0
*
* @param array $select Array of options for the dropdown.
* @param array $taxonomies Array of original passed in post types.
*/
$select = apply_filters( 'cptui_taxonomies_dropdown_options', $select, $taxonomies );
echo $ui->get_select_input( // phpcs:ignore.
[
'namearray' => 'cptui_selected_taxonomy',
'name' => 'taxonomy',
'selections' => $select, // phpcs:ignore.
'wrap' => false,
]
);
}
}
/**
* Get the selected taxonomy from the $_POST global.
*
* @since 1.0.0
*
* @internal
*
* @param bool $taxonomy_deleted Whether or not a taxonomy was recently deleted. Optional. Default false.
* @return bool|string False on no result, sanitized taxonomy if set.
*/
function cptui_get_current_taxonomy( $taxonomy_deleted = false ) {
$tax = false;
if ( ! empty( $_POST ) ) {
if ( ! empty( $_POST['cptui_select_taxonomy_nonce_field'] ) ) {
check_admin_referer( 'cptui_select_taxonomy_nonce_action', 'cptui_select_taxonomy_nonce_field' );
}
if ( isset( $_POST['cptui_selected_taxonomy']['taxonomy'] ) ) {
$tax = sanitize_text_field( wp_unslash( $_POST['cptui_selected_taxonomy']['taxonomy'] ) );
} elseif ( $taxonomy_deleted ) {
$taxonomies = cptui_get_taxonomy_data();
$tax = key( $taxonomies );
} elseif ( isset( $_POST['cpt_custom_tax']['name'] ) ) {
// Return the submitted value.
if ( ! in_array( $_POST['cpt_custom_tax']['name'], cptui_reserved_taxonomies(), true ) ) {
$tax = sanitize_text_field( wp_unslash( $_POST['cpt_custom_tax']['name'] ) );
} else {
// Return the original value since user tried to submit a reserved term.
$tax = sanitize_text_field( wp_unslash( $_POST['tax_original'] ) ); // phpcs:ignore.
}
}
} elseif ( ! empty( $_GET ) && isset( $_GET['cptui_taxonomy'] ) ) {
$tax = sanitize_text_field( wp_unslash( $_GET['cptui_taxonomy'] ) );
} else {
$taxonomies = cptui_get_taxonomy_data();
if ( ! empty( $taxonomies ) ) {
// Will return the first array key.
$tax = key( $taxonomies );
}
}
/**
* Filters the current taxonomy to edit.
*
* @since 1.3.0
*
* @param string $tax Taxonomy slug.
*/
return apply_filters( 'cptui_current_taxonomy', $tax );
}
/**
* Delete our custom taxonomy from the array of taxonomies.
*
* @since 1.0.0
*
* @internal
*
* @param array $data The $_POST values. Optional.
* @return bool|string False on failure, string on success.
*/
function cptui_delete_taxonomy( $data = [] ) {
if ( is_string( $data ) && taxonomy_exists( $data ) ) {
$slug = $data;
$data = [];
$data['name'] = $slug;
}
// Check if they selected one to delete.
if ( empty( $data['name'] ) ) {
return cptui_admin_notices( 'error', '', false, esc_html__( 'Please provide a taxonomy to delete', 'custom-post-type-ui' ) );
}
/**
* Fires before a taxonomy is deleted from our saved options.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data we are deleting.
*/
do_action( 'cptui_before_delete_taxonomy', $data );
$taxonomies = cptui_get_taxonomy_data();
if ( array_key_exists( strtolower( $data['name'] ), $taxonomies ) ) {
unset( $taxonomies[ $data['name'] ] );
/**
* Filters whether or not 3rd party options were saved successfully within taxonomy deletion.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else saved successfully. Default false.
* @param array $taxonomies Array of our updated taxonomies data.
* @param array $data Array of submitted taxonomy to update.
*/
if ( false === ( $success = apply_filters( 'cptui_taxonomy_delete_tax', false, $taxonomies, $data ) ) ) { // phpcs:ignore.
$success = update_option( 'cptui_taxonomies', $taxonomies );
}
}
delete_option( "default_term_{$data['name']}" );
/**
* Fires after a taxonomy is deleted from our saved options.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data that was deleted.
*/
do_action( 'cptui_after_delete_taxonomy', $data );
// Used to help flush rewrite rules on init.
set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
if ( isset( $success ) ) {
return 'delete_success';
}
return 'delete_fail';
}
/**
* Add to or update our CPTUI option with new data.
*
* @since 1.0.0
*
* @internal
*
* @param array $data Array of taxonomy data to update. Optional.
* @return bool|string False on failure, string on success.
*/
function cptui_update_taxonomy( $data = [] ) {
/**
* Fires before a taxonomy is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data we are updating.
*/
do_action( 'cptui_before_update_taxonomy', $data );
// They need to provide a name.
if ( empty( $data['cpt_custom_tax']['name'] ) ) {
return cptui_admin_notices( 'error', '', false, esc_html__( 'Please provide a taxonomy name', 'custom-post-type-ui' ) );
}
// Maybe a little harsh, but we shouldn't be saving THAT frequently.
delete_option( "default_term_{$data['cpt_custom_tax']['name']}" );
if ( empty( $data['cpt_post_types'] ) ) {
add_filter( 'cptui_custom_error_message', 'cptui_empty_cpt_on_taxonomy' );
return 'error';
}
if ( ! empty( $data['tax_original'] ) && $data['tax_original'] !== $data['cpt_custom_tax']['name'] ) {
if ( ! empty( $data['update_taxonomy'] ) ) {
add_filter( 'cptui_convert_taxonomy_terms', '__return_true' );
}
}
foreach ( $data as $key => $value ) {
if ( is_string( $value ) ) {
$data[ $key ] = sanitize_text_field( $value );
} else {
array_map( 'sanitize_text_field', $data[ $key ] );
}
}
if ( false !== strpos( $data['cpt_custom_tax']['name'], '\'' ) ||
false !== strpos( $data['cpt_custom_tax']['name'], '\"' ) ||
false !== strpos( $data['cpt_custom_tax']['rewrite_slug'], '\'' ) ||
false !== strpos( $data['cpt_custom_tax']['rewrite_slug'], '\"' ) ) {
add_filter( 'cptui_custom_error_message', 'cptui_slug_has_quotes' );
return 'error';
}
$taxonomies = cptui_get_taxonomy_data();
/**
* Check if we already have a post type of that name.
*
* @since 1.3.0
*
* @param bool $value Assume we have no conflict by default.
* @param string $value Post type slug being saved.
* @param array $post_types Array of existing post types from CPTUI.
*/
$slug_exists = apply_filters( 'cptui_taxonomy_slug_exists', false, $data['cpt_custom_tax']['name'], $taxonomies );
if ( true === $slug_exists ) {
add_filter( 'cptui_custom_error_message', 'cptui_slug_matches_taxonomy' );
return 'error';
}
if ( empty( $data['cpt_tax_labels'] ) || ! is_array( $data['cpt_tax_labels'] ) ) {
$data['cpt_tax_labels'] = [];
}
foreach ( $data['cpt_tax_labels'] as $key => $label ) {
if ( empty( $label ) ) {
unset( $data['cpt_tax_labels'][ $key ] );
}
$label = str_replace( '"', '', htmlspecialchars_decode( $label ) );
$label = htmlspecialchars( $label, ENT_QUOTES );
$label = trim( $label );
$data['cpt_tax_labels'][ $key ] = stripslashes_deep( $label );
}
$label = ucwords( str_replace( '_', ' ', $data['cpt_custom_tax']['name'] ) );
if ( ! empty( $data['cpt_custom_tax']['label'] ) ) {
$label = str_replace( '"', '', htmlspecialchars_decode( $data['cpt_custom_tax']['label'] ) );
$label = htmlspecialchars( stripslashes( $label ), ENT_QUOTES );
}
$name = trim( $data['cpt_custom_tax']['name'] );
$singular_label = ucwords( str_replace( '_', ' ', $data['cpt_custom_tax']['name'] ) );
if ( ! empty( $data['cpt_custom_tax']['singular_label'] ) ) {
$singular_label = str_replace( '"', '', htmlspecialchars_decode( $data['cpt_custom_tax']['singular_label'] ) );
$singular_label = htmlspecialchars( stripslashes( $singular_label ) );
}
$description = stripslashes_deep( $data['cpt_custom_tax']['description'] );
$query_var_slug = trim( $data['cpt_custom_tax']['query_var_slug'] );
$rewrite_slug = trim( $data['cpt_custom_tax']['rewrite_slug'] );
$rest_base = trim( $data['cpt_custom_tax']['rest_base'] );
$rest_controller_class = trim( $data['cpt_custom_tax']['rest_controller_class'] );
$rest_namespace = trim( $data['cpt_custom_tax']['rest_namespace'] );
$show_quickpanel_bulk = ! empty( $data['cpt_custom_tax']['show_in_quick_edit'] ) ? disp_boolean( $data['cpt_custom_tax']['show_in_quick_edit'] ) : '';
$default_term = trim( $data['cpt_custom_tax']['default_term'] );
$meta_box_cb = trim( $data['cpt_custom_tax']['meta_box_cb'] );
// We may or may not need to force a boolean false keyword.
$maybe_false = strtolower( trim( $data['cpt_custom_tax']['meta_box_cb'] ) );
if ( 'false' === $maybe_false ) {
$meta_box_cb = $maybe_false;
}
$taxonomies[ $data['cpt_custom_tax']['name'] ] = [
'name' => $name,
'label' => $label,
'singular_label' => $singular_label,
'description' => $description,
'public' => disp_boolean( $data['cpt_custom_tax']['public'] ),
'publicly_queryable' => disp_boolean( $data['cpt_custom_tax']['publicly_queryable'] ),
'hierarchical' => disp_boolean( $data['cpt_custom_tax']['hierarchical'] ),
'show_ui' => disp_boolean( $data['cpt_custom_tax']['show_ui'] ),
'show_in_menu' => disp_boolean( $data['cpt_custom_tax']['show_in_menu'] ),
'show_in_nav_menus' => disp_boolean( $data['cpt_custom_tax']['show_in_nav_menus'] ),
'query_var' => disp_boolean( $data['cpt_custom_tax']['query_var'] ),
'query_var_slug' => $query_var_slug,
'rewrite' => disp_boolean( $data['cpt_custom_tax']['rewrite'] ),
'rewrite_slug' => $rewrite_slug,
'rewrite_withfront' => $data['cpt_custom_tax']['rewrite_withfront'],
'rewrite_hierarchical' => $data['cpt_custom_tax']['rewrite_hierarchical'],
'show_admin_column' => disp_boolean( $data['cpt_custom_tax']['show_admin_column'] ),
'show_in_rest' => disp_boolean( $data['cpt_custom_tax']['show_in_rest'] ),
'show_tagcloud' => disp_boolean( $data['cpt_custom_tax']['show_tagcloud'] ),
'sort' => disp_boolean( $data['cpt_custom_tax']['sort'] ),
'show_in_quick_edit' => $show_quickpanel_bulk,
'rest_base' => $rest_base,
'rest_controller_class' => $rest_controller_class,
'rest_namespace' => $rest_namespace,
'labels' => $data['cpt_tax_labels'],
'meta_box_cb' => $meta_box_cb,
'default_term' => $default_term,
];
$taxonomies[ $data['cpt_custom_tax']['name'] ]['object_types'] = $data['cpt_post_types'];
/**
* Filters final data to be saved right before saving taxoomy data.
*
* @since 1.6.0
*
* @param array $taxonomies Array of final taxonomy data to save.
* @param string $name Taxonomy slug for taxonomy being saved.
*/
$taxonomies = apply_filters( 'cptui_pre_save_taxonomy', $taxonomies, $name );
/**
* Filters whether or not 3rd party options were saved successfully within taxonomy add/update.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else saved successfully. Default false.
* @param array $taxonomies Array of our updated taxonomies data.
* @param array $data Array of submitted taxonomy to update.
*/
if ( false === ( $success = apply_filters( 'cptui_taxonomy_update_save', false, $taxonomies, $data ) ) ) { // phpcs:ignore.
$success = update_option( 'cptui_taxonomies', $taxonomies );
}
/**
* Fires after a taxonomy is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data that was updated.
*/
do_action( 'cptui_after_update_taxonomy', $data );
// Used to help flush rewrite rules on init.
set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
if ( isset( $success ) && 'new' === $data['cpt_tax_status'] ) {
return 'add_success';
}
return 'update_success';
}
/**
* Return an array of names that users should not or can not use for taxonomy names.
*
* @since 1.3.0
*
* @return array $value Array of names that are recommended against.
*/
function cptui_reserved_taxonomies() {
$reserved = [
'action',
'attachment',
'attachment_id',
'author',
'author_name',
'calendar',
'cat',
'category',
'category__and',
'category__in',
'category__not_in',
'category_name',
'comments_per_page',
'comments_popup',
'cpage',
'custom',
'customize_messenger_channel',
'customized',
'date',
'day',
'debug',
'embed',
'error',
'exact',
'feed',
'fields',
'hour',
'include',
'link_category',
'm',
'minute',
'monthnum',
'more',
'name',
'nav_menu',
'nonce',
'nopaging',
'offset',
'order',
'orderby',
'output',
'p',
'page',
'page_id',
'paged',
'pagename',
'pb',
'perm',
'post',
'post__in',
'post__not_in',
'post_format',
'post_mime_type',
'post_status',
'post_tag',
'post_type',
'posts',
'posts_per_archive_page',
'posts_per_page',
'preview',
'robots',
's',
'search',
'second',
'sentence',
'showposts',
'static',
'status',
'subpost',
'subpost_id',
'tag',
'tag__and',
'tag__in',
'tag__not_in',
'tag_id',
'tag_slug__and',
'tag_slug__in',
'taxonomy',
'tb',
'term',
'terms',
'theme',
'themes',
'title',
'type',
'types',
'w',
'withcomments',
'withoutcomments',
'year',
];
/**
* Filters the list of reserved post types to check against.
* 3rd party plugin authors could use this to prevent duplicate post types.
*
* @since 1.0.0
*
* @param array $value Array of post type slugs to forbid.
*/
$custom_reserved = apply_filters( 'cptui_reserved_taxonomies', [] );
if ( is_string( $custom_reserved ) && ! empty( $custom_reserved ) ) {
$reserved[] = $custom_reserved;
} elseif ( is_array( $custom_reserved ) && ! empty( $custom_reserved ) ) {
foreach ( $custom_reserved as $slug ) {
$reserved[] = $slug;
}
}
return $reserved;
}
/**
* Convert taxonomies.
*
* @since 1.3.0
*
* @internal
*
* @param string $original_slug Original taxonomy slug. Optional. Default empty string.
* @param string $new_slug New taxonomy slug. Optional. Default empty string.
*/
function cptui_convert_taxonomy_terms( $original_slug = '', $new_slug = '' ) {
global $wpdb;
$args = [
'taxonomy' => $original_slug,
'hide_empty' => false,
'fields' => 'ids',
];
$term_ids = get_terms( $args );
if ( is_int( $term_ids ) ) {
$term_ids = (array) $term_ids;
}
if ( is_array( $term_ids ) && ! empty( $term_ids ) ) {
$term_ids = implode( ',', $term_ids );
$query = "UPDATE `{$wpdb->term_taxonomy}` SET `taxonomy` = %s WHERE `taxonomy` = %s AND `term_id` IN ( {$term_ids} )";
$wpdb->query( // phpcs:ignore.
$wpdb->prepare( $query, $new_slug, $original_slug ) // phpcs:ignore.
);
}
cptui_delete_taxonomy( $original_slug );
}
/**
* Checks if we are trying to register an already registered taxonomy slug.
*
* @since 1.3.0
*
* @param bool $slug_exists Whether or not the post type slug exists. Optional. Default false.
* @param string $taxonomy_slug The post type slug being saved. Optional. Default empty string.
* @param array $taxonomies Array of CPTUI-registered post types. Optional.
*
* @return bool
*/
function cptui_check_existing_taxonomy_slugs( $slug_exists = false, $taxonomy_slug = '', $taxonomies = [] ) {
// If true, then we'll already have a conflict, let's not re-process.
if ( true === $slug_exists ) {
return $slug_exists;
}
if ( ! is_array( $taxonomies ) ) {
return $slug_exists;
}
// Check if CPTUI has already registered this slug.
if ( array_key_exists( strtolower( $taxonomy_slug ), $taxonomies ) ) { // phpcs:ignore.
return true;
}
// Check if we're registering a reserved post type slug.
if ( in_array( $taxonomy_slug, cptui_reserved_taxonomies() ) ) { // phpcs:ignore.
return true;
}
// Check if other plugins have registered this same slug.
$public = get_taxonomies(
[
'_builtin' => false,
'public' => true,
]
);
$private = get_taxonomies(
[
'_builtin' => false,
'public' => false,
]
);
$registered_taxonomies = array_merge( $public, $private );
if ( in_array( $taxonomy_slug, $registered_taxonomies, true ) ) {
return true;
}
// If we're this far, it's false.
return $slug_exists;
}
add_filter( 'cptui_taxonomy_slug_exists', 'cptui_check_existing_taxonomy_slugs', 10, 3 );
/**
* Handle the save and deletion of taxonomy data.
*
* @since 1.4.0
*/
function cptui_process_taxonomy() {
if ( wp_doing_ajax() ) {
return;
}
if ( ! is_admin() ) {
return;
}
if ( ! empty( $_GET ) && isset( $_GET['page'] ) && 'cptui_manage_taxonomies' !== $_GET['page'] ) {
return;
}
if ( ! empty( $_POST ) ) {
$result = '';
if ( isset( $_POST['cpt_submit'] ) ) {
check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
$data = cptui_filtered_taxonomy_post_global();
$result = cptui_update_taxonomy( $data );
} elseif ( isset( $_POST['cpt_delete'] ) ) {
check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
$filtered_data = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
$result = cptui_delete_taxonomy( $filtered_data );
add_filter( 'cptui_taxonomy_deleted', '__return_true' );
}
if ( $result && is_callable( "cptui_{$result}_admin_notice" ) ) {
add_action( 'admin_notices', "cptui_{$result}_admin_notice" );
}
if ( isset( $_POST['cpt_delete'] ) && empty( cptui_get_taxonomy_slugs() ) ) {
wp_safe_redirect(
add_query_arg(
[ 'page' => 'cptui_manage_taxonomies' ],
cptui_admin_url( 'admin.php?page=cptui_manage_taxonomies' )
)
);
}
}
}
add_action( 'init', 'cptui_process_taxonomy', 8 );
/**
* Handle the conversion of taxonomy terms.
*
* This function came to be because we needed to convert AFTER registration.
*
* @since 1.4.3
*/
function cptui_do_convert_taxonomy_terms() {
/**
* Whether or not to convert taxonomy terms.
*
* @since 1.4.3
*
* @param bool $value Whether or not to convert.
*/
if ( apply_filters( 'cptui_convert_taxonomy_terms', false ) ) {
check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
$original = filter_input( INPUT_POST, 'tax_original', FILTER_SANITIZE_SPECIAL_CHARS );
$new = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
// Return early if either fails to successfully validate.
if ( ! $original || ! $new ) {
return;
}
cptui_convert_taxonomy_terms( sanitize_text_field( $original ), sanitize_text_field( $new['name'] ) );
}
}
add_action( 'init', 'cptui_do_convert_taxonomy_terms' );
/**
* Handles slug_exist checks for cases of editing an existing taxonomy.
*
* @since 1.5.3
*
* @param bool $slug_exists Current status for exist checks.
* @param string $taxonomy_slug Taxonomy slug being processed.
* @param array $taxonomies CPTUI taxonomies.
* @return bool
*/
function cptui_updated_taxonomy_slug_exists( $slug_exists, $taxonomy_slug = '', $taxonomies = [] ) {
if (
( ! empty( $_POST['cpt_tax_status'] ) && 'edit' === $_POST['cpt_tax_status'] ) && // phpcs:ignore WordPress.Security.NonceVerification
! in_array( $taxonomy_slug, cptui_reserved_taxonomies(), true ) && // phpcs:ignore WordPress.Security.NonceVerification
( ! empty( $_POST['tax_original'] ) && $taxonomy_slug === $_POST['tax_original'] ) // phpcs:ignore WordPress.Security.NonceVerification
) {
$slug_exists = false;
}
return $slug_exists;
}
add_filter( 'cptui_taxonomy_slug_exists', 'cptui_updated_taxonomy_slug_exists', 11, 3 );
/**
* Sanitize and filter the $_POST global and return a reconstructed array of the parts we need.
*
* Used for when managing taxonomies.
*
* @since 1.10.0
* @return array
*/
function cptui_filtered_taxonomy_post_global() {
$filtered_data = [];
$default_arrays = [
'cpt_custom_tax',
'cpt_tax_labels',
'cpt_post_types',
'update_taxonomy',
];
$third_party_items_arrays = apply_filters(
'cptui_filtered_taxonomy_post_global_arrays',
(array) [] // phpcs:ignore.
);
$items_arrays = array_merge( $default_arrays, $third_party_items_arrays );
foreach ( $items_arrays as $item ) {
$first_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
if ( $first_result ) {
$filtered_data[ $item ] = $first_result;
}
}
$default_strings = [
'tax_original',
'cpt_tax_status',
];
$third_party_items_strings = apply_filters(
'cptui_filtered_taxonomy_post_global_strings',
(array) [] // phpcs:ignore.
);
$items_strings = array_merge( $default_strings, $third_party_items_strings );
foreach ( $items_strings as $item ) {
$second_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_SPECIAL_CHARS );
if ( $second_result ) {
$filtered_data[ $item ] = $second_result;
}
}
return $filtered_data;
}
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Content for the Debug Info tab.
* @since 1.2.0
* @internal
*/
function cptui_render_debuginfo_section() {
$debuginfo = new CPTUI_Debug_Info();
echo '<form id="cptui_debug_info" method="post">';
$debuginfo->tab_site_info();
wp_nonce_field( 'cptui_debuginfo_nonce_action', 'cptui_debuginfo_nonce_field' );
if ( ! empty( $_POST ) && isset( $_POST['cptui_debug_info_email'] ) && isset( $_POST['cptui_debuginfo_nonce_field'] ) ) {
if ( wp_verify_nonce( 'cptui_debuginfo_nonce_field', 'cptui_debuginfo_nonce_action' ) ) {
$email_args = [];
$email_args['email'] = sanitize_text_field( $_POST['cptui_debug_info_email'] );
$debuginfo->send_email( $email_args );
}
}
echo '<p><label for="cptui_debug_info_email">' . esc_html__( 'Please provide an email address to send debug information to: ', 'custom-post-type-ui' ) . '</label><input type="email" id="cptui_debug_info_email" name="cptui_debug_info_email" value="" /></p>';
/**
* Filters the text value to use on the button when sending debug information.
*
* @param string $value Text to use for the button.
*
* @since 1.2.0
*/
echo '<p><input type="submit" class="button-primary" name="cptui_send_debug_email" value="' . esc_attr( apply_filters( 'cptui_debug_email_submit_button', __( 'Send debug info', 'custom-post-type-ui' ) ) ) . '" /></p>';
echo '</form>';
/**
* Fires after the display of the site information.
* @since 1.3.0
*/
do_action( 'cptui_after_site_info' );
}
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Content for the Get Code tab.
* @since 1.2.0
* @internal
*/
function cptui_render_getcode_section() {
?>
<h1><?php esc_html_e( 'Get Post Type and Taxonomy Code', 'custom-post-type-ui' ); ?></h1>
<h2><?php esc_html_e( 'All Custom Post Type UI Post Types', 'custom-post-type-ui' ); ?></h2>
<p><?php esc_html_e( 'All of the selectable code snippets below are useful if you wish to migrate away from Custom Post Type UI and retain your existing registered post types or taxonomies.', 'custom-post-type-ui' ); ?></p>
<?php $cptui_post_types = cptui_get_post_type_data(); ?>
<p>
<label for="cptui_post_type_get_code"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
</p>
<textarea name="cptui_post_type_get_code" id="cptui_post_type_get_code" class="large-text cptui_post_type_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_post_type_code( $cptui_post_types ); ?></textarea>
<?php
if ( ! empty( $cptui_post_types ) ) {
foreach ( $cptui_post_types as $post_type ) {
?>
<h2 id="<?php echo esc_attr( $post_type['name'] ); ?>">
<?php
$type = ! empty( $post_type['label'] ) ? esc_html( $post_type['label'] ) : esc_html( $post_type['name'] );
printf( esc_html__( '%s Post Type', 'custom-post-type-ui' ), esc_html( $type ) ); ?></h2>
<p>
<label for="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
</p>
<textarea name="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>" id="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>" class="large-text cptui_post_type_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_post_type_code( [ $post_type ], true ); ?></textarea>
<?php
}
}
?>
<h2><?php esc_html_e( 'All Custom Post Type UI Taxonomies', 'custom-post-type-ui' ); ?></h2>
<?php $cptui_taxonomies = cptui_get_taxonomy_data(); ?>
<p>
<label for="cptui_tax_get_code"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
</p>
<textarea name="cptui_tax_get_code" id="cptui_tax_get_code" class="large-text cptui_tax_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_taxonomy_code( $cptui_taxonomies ); ?></textarea>
<?php
if ( ! empty( $cptui_taxonomies ) ) {
foreach ( $cptui_taxonomies as $taxonomy ) {
?>
<h2 id="<?php echo esc_attr( $taxonomy['name'] ); ?>">
<?php
$tax = ! empty( $taxonomy['label'] ) ? esc_html( $taxonomy['label'] ) : esc_html( $taxonomy['name'] );
printf( esc_html__( '%s Taxonomy', 'custom-post-type-ui' ), esc_html( $tax ) );
?>
</h2>
<p>
<label for="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
</p>
<textarea name="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>" id="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>" class="large-text cptui_tax_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_taxonomy_code( [ $taxonomy ], true ); ?></textarea>
<?php
}
}
?>
<?php
}
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Display our copy-able code for registered post types.
*
* @param array $cptui_post_types Array of post types to render. Optional.
* @param bool $single Whether or not we are rendering a single post type. Optional. Default false.
*
* @since 1.2.0 Added $single parameter.
* @since 1.0.0
* @since 1.2.0 Added $cptui_post_types parameter.
*/
function cptui_get_post_type_code( $cptui_post_types = [], $single = false ) {
// Whitespace very much matters here, thus why it's all flush against the left side.
if ( ! empty( $cptui_post_types ) ) {
$callback = 'cptui_register_my_cpts';
if ( $single ) {
$key = key( $cptui_post_types );
$callback = 'cptui_register_my_cpts_' . str_replace( '-', '_', esc_html( $cptui_post_types[ $key ]['name'] ) );
}
?>
function <?php echo esc_html( $callback ); ?>() {
<?php
// Space before this line reflects in textarea.
foreach ( $cptui_post_types as $type ) {
echo cptui_get_single_post_type_registery( $type );
}
?>
}
add_action( 'init', '<?php echo esc_html( $callback ); ?>' );
<?php
} else {
esc_html_e( 'No post types to display at this time', 'custom-post-type-ui' );
}
}
/**
* Create output for single post type to be ready for copy/paste from Get Code.
*
* @param array $post_type Post type data to output. Optional.
*
* @since 1.0.0
*/
function cptui_get_single_post_type_registery( $post_type = [] ) {
/* This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
$post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', 'true', $post_type['name'], $post_type );
/* This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
$user_supports_params = apply_filters( 'cptui_user_supports_params', [], $post_type['name'], $post_type );
if ( is_array( $user_supports_params ) ) {
$post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
}
$yarpp = false; // Prevent notices.
if ( ! empty( $post_type['custom_supports'] ) ) {
$custom = explode( ',', $post_type['custom_supports'] );
foreach ( $custom as $part ) {
// We'll handle YARPP separately.
if ( in_array( $part, [ 'YARPP', 'yarpp' ], true ) ) {
$yarpp = true;
continue;
}
$post_type['supports'][] = $part;
}
}
$show_graphql = isset( $post_type['show_in_graphql'] ) ? (bool) $post_type['show_in_graphql'] : false;
$rewrite_withfront = '';
$rewrite = get_disp_boolean( $post_type['rewrite'] );
if ( false !== $rewrite ) {
$rewrite = disp_boolean( $post_type['rewrite'] );
$rewrite_slug = ' "slug" => "' . $post_type['name'] . '",';
if ( ! empty( $post_type['rewrite_slug'] ) ) {
$rewrite_slug = ' "slug" => "' . $post_type['rewrite_slug'] . '",';
}
$withfront = disp_boolean( $post_type['rewrite_withfront'] );
if ( ! empty( $withfront ) ) {
$rewrite_withfront = ' "with_front" => ' . $withfront . ' ';
}
if ( ! empty( $post_type['rewrite_slug'] ) || ! empty( $post_type['rewrite_withfront'] ) ) {
$rewrite_start = '[';
$rewrite_end = ']';
$rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
}
} else {
$rewrite = disp_boolean( $post_type['rewrite'] );
}
$has_archive = get_disp_boolean( $post_type['has_archive'] );
if ( false !== $has_archive ) {
$has_archive = disp_boolean( $post_type['has_archive'] );
if ( ! empty( $post_type['has_archive_string'] ) ) {
$has_archive = '"' . $post_type['has_archive_string'] . '"';
}
} else {
$has_archive = disp_boolean( $post_type['has_archive'] );
}
$supports = '';
// Do a little bit of php work to get these into strings.
if ( ! empty( $post_type['supports'] ) && is_array( $post_type['supports'] ) ) {
$supports = '[ "' . implode( '", "', $post_type['supports'] ) . '" ]';
}
if ( in_array( 'none', $post_type['supports'], true ) ) {
$supports = 'false';
}
$taxonomies = '';
if ( ! empty( $post_type['taxonomies'] ) && is_array( $post_type['taxonomies'] ) ) {
$taxonomies = '[ "' . implode( '", "', $post_type['taxonomies'] ) . '" ]';
}
if ( in_array( $post_type['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
$post_type['query_var'] = disp_boolean( $post_type['query_var'] );
}
if ( ! empty( $post_type['query_var_slug'] ) ) {
$post_type['query_var'] = '"' . $post_type['query_var_slug'] . '"';
}
if ( empty( $post_type['show_in_rest'] ) ) {
$post_type['show_in_rest'] = 'false';
}
$rest_controller_class = ! empty( $post_type['rest_controller_class'] ) ? $post_type['rest_controller_class'] : 'WP_REST_Posts_Controller';
$rest_namespace = ! empty( $post_type['rest_namespace'] ) ? $post_type['rest_namespace'] : 'wp/v2';
$show_in_menu = get_disp_boolean( $post_type['show_in_menu'] );
if ( false !== $show_in_menu ) {
$show_in_menu = disp_boolean( $post_type['show_in_menu'] );
if ( ! empty( $post_type['show_in_menu_string'] ) ) {
$show_in_menu = '"' . $post_type['show_in_menu_string'] . '"';
}
} else {
$show_in_menu = disp_boolean( $post_type['show_in_menu'] );
}
$delete_with_user = 'false';
if ( isset( $post_type['delete_with_user'] ) ) {
$delete_with_user = disp_boolean( $post_type['delete_with_user'] );
}
$can_export = 'true';
if ( isset( $post_type['can_export'] ) ) {
$can_export = disp_boolean( $post_type['can_export'] );
}
$public = isset( $post_type['public'] ) ? disp_boolean( $post_type['public'] ) : 'true';
$show_in_nav_menus = ( ! empty( $post_type['show_in_nav_menus'] ) && false !== get_disp_boolean( $post_type['show_in_nav_menus'] ) ) ? 'true' : 'false';
if ( empty( $post_type['show_in_nav_menus'] ) ) {
$show_in_nav_menus = $public;
}
$capability_type = '"post"';
if ( ! empty( $post_type['capability_type'] ) ) {
$capability_type = '"' . $post_type['capability_type'] . '"';
if ( false !== strpos( $post_type['capability_type'], ',' ) ) {
$caps = array_map( 'trim', explode( ',', $post_type['capability_type'] ) );
if ( count( $caps ) > 2 ) {
$caps = array_slice( $caps, 0, 2 );
}
$capability_type = '[ "' . $caps[0] . '", "' . $caps[1] . '" ]';
}
}
$post_type['description'] = addslashes( $post_type['description'] );
$my_theme = wp_get_theme();
$textdomain = $my_theme->get( 'TextDomain' );
if ( empty( $textdomain ) ) {
$textdomain = 'custom-post-type-ui';
}
?>
/**
* Post Type: <?php echo $post_type['label']; ?>.
*/
$labels = [
"name" => esc_html__( "<?php echo $post_type['label']; ?>", "<?php echo $textdomain; ?>" ),
"singular_name" => esc_html__( "<?php echo $post_type['singular_label']; ?>", "<?php echo $textdomain; ?>" ),
<?php
foreach ( $post_type['labels'] as $key => $label ) {
if ( ! empty( $label ) ) {
if ( 'parent' === $key && ! array_key_exists( 'parent_item_colon', $post_type['labels'] ) ) {
// Fix for incorrect label key. See #439.
echo "\t\t" . '"' . 'parent_item_colon' . '" => esc_html__( "' . $label . '", "' . $textdomain . '" ),' . "\n";
} else {
echo "\t\t" . '"' . $key . '" => esc_html__( "' . $label . '", "' . $textdomain . '" ),' . "\n";
}
}
}
?>
];
$args = [
"label" => esc_html__( "<?php echo $post_type['label']; ?>", "<?php echo $textdomain; ?>" ),
"labels" => $labels,
"description" => "<?php echo $post_type['description']; ?>",
"public" => <?php echo disp_boolean( $post_type['public'] ); ?>,
"publicly_queryable" => <?php echo disp_boolean( $post_type['publicly_queryable'] ); ?>,
"show_ui" => <?php echo disp_boolean( $post_type['show_ui'] ); ?>,
"show_in_rest" => <?php echo disp_boolean( $post_type['show_in_rest'] ); ?>,
"rest_base" => "<?php echo $post_type['rest_base']; ?>",
"rest_controller_class" => "<?php echo $rest_controller_class; ?>",
"rest_namespace" => "<?php echo $rest_namespace; ?>",
"has_archive" => <?php echo $has_archive; ?>,
"show_in_menu" => <?php echo $show_in_menu; ?>,
"show_in_nav_menus" => <?php echo $show_in_nav_menus; ?>,
"delete_with_user" => <?php echo $delete_with_user; ?>,
"exclude_from_search" => <?php echo disp_boolean( $post_type['exclude_from_search'] ); ?>,
"capability_type" => <?php echo $capability_type; ?>,
"map_meta_cap" => <?php echo disp_boolean( $post_type['map_meta_cap'] ); ?>,
"hierarchical" => <?php echo disp_boolean( $post_type['hierarchical'] ); ?>,
"can_export" => <?php echo $can_export; ?>,
"rewrite" => <?php echo $rewrite; ?>,
"query_var" => <?php echo $post_type['query_var']; ?>,
<?php if ( ! empty( $post_type['menu_position'] ) ) { ?>
"menu_position" => <?php echo $post_type['menu_position']; ?>,
<?php } ?>
<?php if ( ! empty( $post_type['menu_icon'] ) ) { ?>
"menu_icon" => "<?php echo $post_type['menu_icon']; ?>",
<?php } ?>
<?php if ( ! empty( $post_type['register_meta_box_cb'] ) ) { ?>
"register_meta_box_cb" => "<?php echo $post_type['register_meta_box_cb']; ?>",
<?php } ?>
<?php if ( ! empty( $supports ) ) { ?>
"supports" => <?php echo $supports; ?>,
<?php } ?>
<?php if ( ! empty( $taxonomies ) ) { ?>
"taxonomies" => <?php echo $taxonomies; ?>,
<?php } ?>
<?php if ( true === $yarpp ) { ?>
"yarpp_support" => <?php echo disp_boolean( $yarpp ); ?>,
<?php } ?>
<?php if ( $show_graphql ) : ?>
"show_in_graphql" => <?php echo disp_boolean( $post_type['show_in_graphql'] ); ?>,
"graphql_single_name" => "<?php echo esc_html( $post_type['graphql_single_name'] ); ?>",
"graphql_plural_name" => "<?php echo esc_html( $post_type['graphql_plural_name'] ); ?>",
<?php else: ?>
"show_in_graphql" => <?php echo disp_boolean( false ); ?>,
<?php endif; ?>
];
register_post_type( "<?php echo esc_html( $post_type['name'] ); ?>", $args );
<?php
}
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Display our copy-able code for registered taxonomies.
*
* @param array $cptui_taxonomies Array of taxonomies to render. Optional.
* @param bool $single Whether or not we are rendering a single taxonomy. Optional. Default false.
*
* @since 1.2.0 Added $single parameter.
* @since 1.0.0
* @since 1.2.0 Added $cptui_taxonomies parameter.
*/
function cptui_get_taxonomy_code( $cptui_taxonomies = [], $single = false ) {
if ( ! empty( $cptui_taxonomies ) ) {
$callback = 'cptui_register_my_taxes';
if ( $single ) {
$key = key( $cptui_taxonomies );
$callback = 'cptui_register_my_taxes_' . str_replace( '-', '_', esc_html( $cptui_taxonomies[ $key ]['name'] ) );
}
ob_start();
?>
function <?php echo esc_html( $callback ); ?>() {
<?php
foreach ( $cptui_taxonomies as $tax ) {
echo cptui_get_single_taxonomy_registery( $tax );
}
?>
}
add_action( 'init', '<?php echo esc_html( $callback ); ?>' );
<?php
} else {
esc_html_e( 'No taxonomies to display at this time', 'custom-post-type-ui' );
}
echo trim( ob_get_clean() );
}
/**
* Create output for single taxonomy to be ready for copy/paste from Get Code.
*
* @param array $taxonomy Taxonomy data to output. Optional.
*
* @since 1.0.0
*/
function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
$post_types = "''";
if ( is_array( $taxonomy['object_types'] ) ) {
$post_types = '[ "' . implode( '", "', $taxonomy['object_types'] ) . '" ]';
}
if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) {
$rewrite = disp_boolean( $taxonomy['rewrite'] );
$rewrite_slug = ' \'slug\' => \'' . $taxonomy['name'] . '\',';
if ( ! empty( $taxonomy['rewrite_slug'] ) ) {
$rewrite_slug = ' \'slug\' => \'' . $taxonomy['rewrite_slug'] . '\',';
}
$rewrite_withfront = '';
$withfront = disp_boolean( $taxonomy['rewrite_withfront'] );
if ( ! empty( $withfront ) ) {
$rewrite_withfront = ' \'with_front\' => ' . $withfront . ', ';
}
$hierarchical = ! empty( $taxonomy['rewrite_hierarchical'] ) ? disp_boolean( $taxonomy['rewrite_hierarchical'] ) : '';
$rewrite_hierarchcial = '';
if ( ! empty( $hierarchical ) ) {
$rewrite_hierarchcial = ' \'hierarchical\' => ' . $hierarchical . ', ';
}
if ( ! empty( $taxonomy['rewrite_slug'] ) || false !== disp_boolean( $taxonomy['rewrite_withfront'] ) ) {
$rewrite_start = '[';
$rewrite_end = ']';
$rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_hierarchcial . $rewrite_end;
}
} else {
$rewrite = disp_boolean( $taxonomy['rewrite'] );
}
$public = isset( $taxonomy['public'] ) ? disp_boolean( $taxonomy['public'] ) : 'true';
$publicly_queryable = isset( $taxonomy['publicly_queryable'] ) ? disp_boolean( $taxonomy['publicly_queryable'] ) : disp_boolean( $taxonomy['public'] );
$show_in_quick_edit = isset( $taxonomy['show_in_quick_edit'] ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] );
$show_tagcloud = isset( $taxonomy['show_tagcloud'] ) ? disp_boolean( $taxonomy['show_tagcloud'] ) : disp_boolean( $taxonomy['show_ui'] );
$show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? 'true' : 'false';
if ( empty( $taxonomy['show_in_menu'] ) ) {
$show_in_menu = disp_boolean( $taxonomy['show_ui'] );
}
$show_in_nav_menus = ( ! empty( $taxonomy['show_in_nav_menus'] ) && false !== get_disp_boolean( $taxonomy['show_in_nav_menus'] ) ) ? 'true' : 'false';
if ( empty( $taxonomy['show_in_nav_menus'] ) ) {
$show_in_nav_menus = $public;
}
$show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? 'true' : 'false';
$rest_base = ! empty( $taxonomy['rest_base'] ) ? $taxonomy['rest_base'] : $taxonomy['name'];
$rest_controller_class = ! empty( $taxonomy['rest_controller_class'] ) ? $taxonomy['rest_controller_class'] : 'WP_REST_Terms_Controller';
$rest_namespace = ! empty( $taxonomy['rest_namespace'] ) ? $taxonomy['rest_namespace'] : 'wp/v2';
$sort = ( ! empty( $taxonomy['sort'] ) && false !== get_disp_boolean( $taxonomy['sort'] ) ) ? 'true' : 'false';
if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
}
$default_term = '';
if ( ! empty( $taxonomy['default_term'] ) ) {
$term_parts = explode( ',', $taxonomy['default_term'] );
$default_term_start = '[';
$default_term_end = ']';
if ( ! empty( $term_parts[0] ) ) {
$default_term .= "'name' => '" . trim( $term_parts[0] ) . "'";
}
if ( ! empty( $term_parts[1] ) ) {
$default_term .= ", 'slug' => '" . trim( $term_parts[1] ) . "'";
}
if ( ! empty( $term_parts[2] ) ) {
$default_term .= ", 'description' => '" . trim( $term_parts[2] ) . "'";
}
$default_term = $default_term_start . $default_term . $default_term_end;
}
$my_theme = wp_get_theme();
$textdomain = $my_theme->get( 'TextDomain' );
if ( empty( $textdomain ) ) {
$textdomain = 'custom-post-type-ui';
}
?>
/**
* Taxonomy: <?php echo esc_html( $taxonomy['label'] ); ?>.
*/
$labels = [
"name" => esc_html__( "<?php echo esc_html( $taxonomy['label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ),
"singular_name" => esc_html__( "<?php echo esc_html( $taxonomy['singular_label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ),
<?php
foreach ( $taxonomy['labels'] as $key => $label ) {
if ( ! empty( $label ) ) {
echo "\t\t" . '"' . esc_html( $key ) . '" => esc_html__( "' . esc_html( $label ) . '", "' . esc_html( $textdomain ) . '" ),' . "\n";
}
}
?>
];
<?php
$show_graphql = isset( $taxonomy['show_in_graphql'] ) ? (bool) $taxonomy['show_in_graphql'] : false;
?>
$args = [
"label" => esc_html__( "<?php echo $taxonomy['label']; ?>", "<?php echo $textdomain; ?>" ),
"labels" => $labels,
"public" => <?php echo $public; ?>,
"publicly_queryable" => <?php echo $publicly_queryable; ?>,
"hierarchical" => <?php echo $taxonomy['hierarchical']; ?>,
"show_ui" => <?php echo disp_boolean( $taxonomy['show_ui'] ); ?>,
"show_in_menu" => <?php echo $show_in_menu; ?>,
"show_in_nav_menus" => <?php echo $show_in_nav_menus; ?>,
"query_var" => <?php echo disp_boolean( $taxonomy['query_var'] ); ?>,
"rewrite" => <?php echo $rewrite; ?>,
"show_admin_column" => <?php echo $taxonomy['show_admin_column']; ?>,
"show_in_rest" => <?php echo $show_in_rest; ?>,
"show_tagcloud" => <?php echo $show_tagcloud; ?>,
"rest_base" => "<?php echo $rest_base; ?>",
"rest_controller_class" => "<?php echo $rest_controller_class; ?>",
"rest_namespace" => "<?php echo $rest_namespace; ?>",
"show_in_quick_edit" => <?php echo $show_in_quick_edit; ?>,
"sort" => <?php echo $sort; ?>,
<?php if ( $show_graphql ) : ?>
"show_in_graphql" => <?php echo disp_boolean( $taxonomy['show_in_graphql'] ); ?>,
"graphql_single_name" => "<?php echo esc_html( $taxonomy['graphql_single_name'] ); ?>",
"graphql_plural_name" => "<?php echo esc_html( $taxonomy['graphql_plural_name'] ); ?>",
<?php else: ?>
"show_in_graphql" => <?php echo disp_boolean( false ); ?>,
<?php endif; ?>
<?php if ( ! empty( $meta_box_cb ) ) { ?>
"meta_box_cb" => <?php echo $meta_box_cb; ?>,
<?php } ?>
<?php if ( ! empty( $default_term ) ) { ?>
"default_term" => <?php echo $default_term; ?>,
<?php } ?>
];
register_taxonomy( "<?php echo esc_html( $taxonomy['name'] ); ?>", <?php echo $post_types; ?>, $args );
<?php
}
<?php
/**
* Custom Post Type UI Tools.
*
* @package CPTUI
* @subpackage Tools
* @author WebDevStudios
* @since 1.0.0
* @license GPL-2.0+
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Enqueue our Custom Post Type UI assets.
*
* @since 1.6.0
*
* @return void
*/
function cptui_tools_assets() {
$current_screen = get_current_screen();
if ( ! is_object( $current_screen ) || 'cpt-ui_page_cptui_tools' !== $current_screen->base ) {
return;
}
if ( wp_doing_ajax() ) {
return;
}
wp_enqueue_style( 'cptui-css' );
}
add_action( 'admin_enqueue_scripts', 'cptui_tools_assets' );
/**
* Register our tabs for the Tools screen.
*
* @since 1.3.0
* @since 1.5.0 Renamed to "Tools"
*
* @internal
*
* @param array $tabs Array of tabs to display. Optional.
* @param string $current_page Current page being shown. Optional. Default empty string.
* @return array Amended array of tabs to show.
*/
function cptui_tools_tabs( $tabs = [], $current_page = '' ) {
if ( 'tools' === $current_page ) {
$classes = [ 'nav-tab' ];
$tabs['page_title'] = get_admin_page_title();
$tabs['tabs'] = [];
$tabs['tabs']['post_types'] = [
'text' => esc_html__( 'Post Types', 'custom-post-type-ui' ),
'classes' => $classes,
'url' => cptui_admin_url( 'admin.php?page=cptui_' . $current_page ),
'aria-selected' => 'false',
];
$tabs['tabs']['taxonomies'] = [
'text' => esc_html__( 'Taxonomies', 'custom-post-type-ui' ),
'classes' => $classes,
'url' => esc_url( add_query_arg( [ 'action' => 'taxonomies' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
'aria-selected' => 'false',
];
$tabs['tabs']['get_code'] = [
'text' => esc_html__( 'Get Code', 'custom-post-type-ui' ),
'classes' => $classes,
'url' => esc_url( add_query_arg( [ 'action' => 'get_code' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
'aria-selected' => 'false',
];
$tabs['tabs']['debuginfo'] = [
'text' => esc_html__( 'Debug Info', 'custom-post-type-ui' ),
'classes' => $classes,
'url' => esc_url( add_query_arg( [ 'action' => 'debuginfo' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
'aria-selected' => 'false',
];
$active_class = 'nav-tab-active';
$action = cptui_get_current_action();
if ( ! empty( $action ) ) {
if ( 'taxonomies' === $action ) {
$tabs['tabs']['taxonomies']['classes'][] = $active_class;
$tabs['tabs']['taxonomies']['aria-selected'] = 'true';
} elseif ( 'get_code' === $action ) {
$tabs['tabs']['get_code']['classes'][] = $active_class;
$tabs['tabs']['get_code']['aria-selected'] = 'true';
} elseif ( 'debuginfo' === $action ) {
$tabs['tabs']['debuginfo']['classes'][] = $active_class;
$tabs['tabs']['debuginfo']['aria-selected'] = 'true';
}
} else {
$tabs['tabs']['post_types']['classes'][] = $active_class;
$tabs['tabs']['post_types']['aria-selected'] = 'true';
}
/**
* Filters the tabs being added for the tools area.
*
* @since 1.5.0
*
* @param array $tabs Array of tabs to show.
* @param string $action Current tab being shown.
* @param string $active_class Class to use to mark the tab active.
*/
$tabs = apply_filters( 'cptui_tools_tabs', $tabs, $action, $active_class );
}
return $tabs;
}
add_filter( 'cptui_get_tabs', 'cptui_tools_tabs', 10, 2 );
/**
* Create our settings page output.
*
* @since 1.0.0
*
* @internal
*/
function cptui_tools() {
$tab = 'post_types';
if ( ! empty( $_GET ) ) { // phpcs:ignore WordPress.Security.NonceVerification
if ( ! empty( $_GET['action'] ) && 'taxonomies' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
$tab = 'taxonomies';
} elseif ( ! empty( $_GET['action'] ) && 'get_code' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
$tab = 'get_code';
} elseif ( ! empty( $_GET['action'] ) && 'debuginfo' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
$tab = 'debuginfo';
}
}
echo '<div class="wrap">';
/**
* Fires right inside the wrap div for the import/export pages.
*
* @since 1.3.0
*
* @deprecated 1.5.0
*/
do_action_deprecated( 'cptui_inside_importexport_wrap', [], '1.5.0', 'cptui_inside_tools_wrap' );
/**
* Fires right inside the wrap div for the tools pages.
*
* @since 1.5.0
*/
do_action( 'cptui_inside_tools_wrap' );
// Create our tabs.
cptui_settings_tab_menu( 'tools' );
/**
* Fires inside the markup for the import/export section.
*
* Allows for more modular control and adding more sections more easily.
*
* @since 1.2.0
*
* @deprecated 1.5.0
*
* @param string $tab Current tab being displayed.
*/
do_action_deprecated( 'cptui_import_export_sections', [ $tab ], '1.5.0', 'cptui_tools_sections' );
/**
* Fires inside the markup for the tools section.
*
* Allows for more modular control and adding more sections more easily.
*
* @since 1.5.0
*
* @param string $tab Current tab being displayed.
*/
do_action( 'cptui_tools_sections', $tab );
echo '</div><!-- End .wrap -->';
}
/**
* Import the posted JSON data from a separate export.
*
* @since 1.0.0
*
* @internal
*
* @param array $postdata $_POST data as json. Optional.
* @return mixed false on nothing to do, otherwise void.
*/
function cptui_import_types_taxes_settings( $postdata = [] ) {
if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) && ! array_key_exists( 'delete', $postdata ) ) {
return false;
}
$doing_wp_cli = ( defined( 'WP_CLI' ) && WP_CLI );
if ( ! $doing_wp_cli && ! check_admin_referer( 'cptui_typetaximport_nonce_action', 'cptui_typetaximport_nonce_field' ) ) {
return 'nonce_fail';
}
$status = 'import_fail';
$success = false;
/**
* Filters the post type data to import.
*
* Allows third parties to provide their own data dump and import instead of going through our UI.
*
* @since 1.2.0
*
* @param bool $value Default to no data.
*/
$third_party_post_type_data = apply_filters( 'cptui_third_party_post_type_import', false );
/**
* Filters the taxonomy data to import.
*
* Allows third parties to provide their own data dump and import instead of going through our UI.
*
* @since 1.2.0
*
* @param bool $value Default to no data.
*/
$third_party_taxonomy_data = apply_filters( 'cptui_third_party_taxonomy_import', false );
if ( false !== $third_party_post_type_data ) {
$postdata['cptui_post_import'] = $third_party_post_type_data;
}
if ( false !== $third_party_taxonomy_data ) {
$postdata['cptui_tax_import'] = $third_party_taxonomy_data;
}
if ( ! empty( $postdata['cptui_post_import'] ) || ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
$settings = null;
if ( ! empty( $postdata['cptui_post_import'] ) ) {
$settings = $postdata['cptui_post_import'];
}
// Add support to delete settings outright, without accessing database.
// Doing double check to protect.
if ( null === $settings && ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
/**
* Filters whether or not 3rd party options were deleted successfully within post type import.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else deleted successfully. Default false.
* @param array $postdata Post type data.
*/
if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
$success = delete_option( 'cptui_post_types' );
}
}
if ( $settings ) {
if ( false !== cptui_get_post_type_data() ) {
/** This filter is documented in /inc/import-export.php */
if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
delete_option( 'cptui_post_types' );
}
}
/**
* Filters whether or not 3rd party options were updated successfully within the post type import.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else updated successfully. Default false.
* @param array $postdata Post type data.
*/
if ( false === ( $success = apply_filters( 'cptui_post_type_import_update_save', false, $postdata ) ) ) { // phpcs:ignore.
$success = update_option( 'cptui_post_types', $settings );
}
}
// Used to help flush rewrite rules on init.
set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
if ( $success ) {
$status = 'import_success';
}
} elseif ( ! empty( $postdata['cptui_tax_import'] ) || ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
$settings = null;
if ( ! empty( $postdata['cptui_tax_import'] ) ) {
$settings = $postdata['cptui_tax_import'];
}
// Add support to delete settings outright, without accessing database.
// Doing double check to protect.
if ( null === $settings && ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
/**
* Filters whether or not 3rd party options were deleted successfully within taxonomy import.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else deleted successfully. Default false.
* @param array $postdata Taxonomy data
*/
if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
$success = delete_option( 'cptui_taxonomies' );
}
}
if ( $settings ) {
if ( false !== cptui_get_taxonomy_data() ) {
/** This filter is documented in /inc/import-export.php */
if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
delete_option( 'cptui_taxonomies' );
}
}
/**
* Filters whether or not 3rd party options were updated successfully within the taxonomy import.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else updated successfully. Default false.
* @param array $postdata Taxonomy data.
*/
if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_update_save', false, $postdata ) ) ) { // phpcs:ignore.
$success = update_option( 'cptui_taxonomies', $settings );
}
}
// Used to help flush rewrite rules on init.
set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
if ( $success ) {
$status = 'import_success';
}
}
return $status;
}
/**
* Content for the Post Types/Taxonomies Tools tab.
*
* @since 1.2.0
*
* @internal
*/
function cptui_render_posttypes_taxonomies_section() {
?>
<p><?php esc_html_e( 'If you are wanting to migrate registered post types or taxonomies from this site to another, that will also use Custom Post Type UI, use the import and export functionality. If you are moving away from Custom Post Type UI, use the information in the "Get Code" tab.', 'custom-post-type-ui' ); ?></p>
<p>
<?php
printf(
'<strong>%s</strong>: %s',
esc_html__( 'NOTE', 'custom-post-type-ui' ),
esc_html__( 'This will not export the associated posts or taxonomy terms, just the settings.', 'custom-post-type-ui' )
);
?>
</p>
<table class="form-table cptui-table">
<?php if ( ! empty( $_GET ) && empty( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification ?>
<tr>
<td class="outer">
<h2><label for="cptui_post_import"><?php esc_html_e( 'Import Post Types', 'custom-post-type-ui' ); ?></label></h2>
<form method="post">
<textarea class="cptui_post_import" placeholder="<?php esc_attr_e( 'Paste content here.', 'custom-post-type-ui' ); ?>" id="cptui_post_import" name="cptui_post_import"></textarea>
<p class="wp-ui-highlight">
<strong><?php esc_html_e( 'Note:', 'custom-post-type-ui' ); ?></strong> <?php esc_html_e( 'Importing will overwrite previous registered settings.', 'custom-post-type-ui' ); ?>
</p>
<p>
<strong><?php esc_html_e( 'To import post types from a different WordPress site, paste the exported content from that site and click the "Import" button.', 'custom-post-type-ui' ); ?></strong>
</p>
<p>
<input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'custom-post-type-ui' ); ?>" />
</p>
<?php wp_nonce_field( 'cptui_typetaximport_nonce_action', 'cptui_typetaximport_nonce_field' ); ?>
</form>
</td>
<td class="outer">
<h2><label for="cptui_post_export"><?php esc_html_e( 'Export Post Types settings', 'custom-post-type-ui' ); ?></label></h2>
<?php
$cptui_post_types = cptui_get_post_type_data();
if ( ! empty( $cptui_post_types ) ) {
foreach ( $cptui_post_types as $type => $values ) {
$cptui_post_types[ $type ]['description'] = wp_slash( html_entity_decode( $values['description'] ) );
}
$content = wp_json_encode( $cptui_post_types );
} else {
$content = esc_html__( 'No post types registered yet.', 'custom-post-type-ui' );
}
?>
<textarea title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'custom-post-type-ui' ); ?>" onclick="this.focus();this.select();" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true" class="cptui_post_import" id="cptui_post_export" name="cptui_post_export"><?php echo $content; // phpcs:ignore. ?></textarea>
<p>
<strong><?php esc_html_e( 'Use the content above to import current post types into a different WordPress site. You can also use this to simply back up your post type settings.', 'custom-post-type-ui' ); ?></strong>
</p>
</td>
</tr>
<?php } elseif ( ! empty( $_GET ) && 'taxonomies' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification ?>
<tr>
<td class="outer">
<h2><label for="cptui_tax_import"><?php esc_html_e( 'Import Taxonomies', 'custom-post-type-ui' ); ?></label></h2>
<form method="post">
<textarea class="cptui_tax_import" placeholder="<?php esc_attr_e( 'Paste content here.', 'custom-post-type-ui' ); ?>" id="cptui_tax_import" name="cptui_tax_import"></textarea>
<p class="wp-ui-highlight">
<strong><?php esc_html_e( 'Note:', 'custom-post-type-ui' ); ?></strong> <?php esc_html_e( 'Importing will overwrite previous registered settings.', 'custom-post-type-ui' ); ?>
</p>
<p>
<strong><?php esc_html_e( 'To import taxonomies from a different WordPress site, paste the exported content from that site and click the "Import" button.', 'custom-post-type-ui' ); ?></strong>
</p>
<p>
<input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'custom-post-type-ui' ); ?>" />
</p>
<?php wp_nonce_field( 'cptui_typetaximport_nonce_action', 'cptui_typetaximport_nonce_field' ); ?>
</form>
</td>
<td class="outer">
<h2><label for="cptui_tax_export"><?php esc_html_e( 'Export Taxonomies settings', 'custom-post-type-ui' ); ?></label></h2>
<?php
$cptui_taxonomies = cptui_get_taxonomy_data();
if ( ! empty( $cptui_taxonomies ) ) {
foreach ( $cptui_taxonomies as $tax => $values ) {
$cptui_taxonomies[ $tax ]['description'] = wp_slash( html_entity_decode( $values['description'] ) );
}
$content = wp_json_encode( $cptui_taxonomies );
} else {
$content = esc_html__( 'No taxonomies registered yet.', 'custom-post-type-ui' );
}
?>
<textarea title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'custom-post-type-ui' ); ?>" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true" class="cptui_tax_import" id="cptui_tax_export" name="cptui_tax_export"><?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput ?></textarea>
<p>
<strong><?php esc_html_e( 'Use the content above to import current taxonomies into a different WordPress site. You can also use this to simply back up your taxonomy settings.', 'custom-post-type-ui' ); ?></strong>
</p>
</td>
</tr>
<?php } ?>
</table>
<?php
}
/**
* Renders various tab sections for the Tools page, based on current tab.
*
* @since 1.2.0
*
* @internal
*
* @param string $tab Current tab to display.
*/
function cptui_render_tools( $tab ) {
if ( 'post_types' === $tab || 'taxonomies' === $tab ) {
cptui_render_posttypes_taxonomies_section();
}
if ( 'get_code' === $tab ) {
cptui_render_getcode_section();
}
if ( 'debuginfo' === $tab ) {
cptui_render_debuginfo_section();
}
}
add_action( 'cptui_tools_sections', 'cptui_render_tools' );
/**
* Handle the import of transferred post types and taxonomies.
*
* @since 1.5.0
*/
function cptui_do_import_types_taxes() {
// phpcs:ignore.
if ( ! empty( $_POST ) && // phpcs:ignore WordPress.Security.NonceVerification
( ! empty( $_POST['cptui_post_import'] ) && isset( $_POST['cptui_post_import'] ) ) || // phpcs:ignore WordPress.Security.NonceVerification
( ! empty( $_POST['cptui_tax_import'] ) && isset( $_POST['cptui_tax_import'] ) ) // phpcs:ignore WordPress.Security.NonceVerification
) {
$data = [];
$decoded_post_data = null;
$decoded_tax_data = null;
if ( ! empty( $_POST['cptui_post_import'] ) ) { // phpcs:ignore.
$decoded_post_data = json_decode( stripslashes_deep( trim( $_POST['cptui_post_import'] ) ), true ); // phpcs:ignore.
}
if ( ! empty( $_POST['cptui_tax_import'] ) ) { // phpcs:ignore.
$decoded_tax_data = json_decode( stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ), true ); // phpcs:ignore.
}
if (
empty( $decoded_post_data ) &&
empty( $decoded_tax_data ) &&
(
! empty( $_POST['cptui_post_import'] ) && '{""}' !== stripslashes_deep( trim( $_POST['cptui_post_import'] ) ) // phpcs:ignore.
) &&
(
! empty( $_POST['cptui_tax_import'] ) && '{""}' !== stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ) // phpcs:ignore.
)
) {
return;
}
if ( null !== $decoded_post_data ) {
$data['cptui_post_import'] = $decoded_post_data;
}
if ( null !== $decoded_tax_data ) {
$data['cptui_tax_import'] = $decoded_tax_data;
}
if ( ! empty( $_POST['cptui_post_import'] ) && '{""}' === stripslashes_deep( trim( $_POST['cptui_post_import'] ) ) ) { // phpcs:ignore.
$data['delete'] = 'type_true';
}
if ( ! empty( $_POST['cptui_tax_import'] ) && '{""}' === stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ) ) { // phpcs:ignore.
$data['delete'] = 'tax_true';
}
$success = cptui_import_types_taxes_settings( $data );
add_action( 'admin_notices', "cptui_{$success}_admin_notice" );
}
}
add_action( 'init', 'cptui_do_import_types_taxes', 8 );
<?php
/**
* Custom Post Type UI Utility Code.
*
* @package CPTUI
* @subpackage Utility
* @author WebDevStudios
* @since 1.3.0
* @license GPL-2.0+
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Edit links that appear on installed plugins list page, for our plugin.
*
* @since 1.0.0
*
* @internal
*
* @param array $links Array of links to display below our plugin listing.
* @return array Amended array of links.
*/
function cptui_edit_plugin_list_links( $links ) {
if ( is_array( $links ) && isset( $links['edit'] ) ) {
// We shouldn't encourage editing our plugin directly.
unset( $links['edit'] );
}
// Add our custom links to the returned array value.
return array_merge(
array(
'<a href="' . admin_url( 'admin.php?page=cptui_main_menu' ) . '">' . esc_html__( 'About', 'custom-post-type-ui' ) . '</a>',
'<a href="' . admin_url( 'admin.php?page=cptui_support' ) . '">' . esc_html__( 'Help', 'custom-post-type-ui' ) . '</a>',
),
$links
);
}
add_filter( 'plugin_action_links_' . plugin_basename( dirname( __DIR__ ) ) . '/custom-post-type-ui.php', 'cptui_edit_plugin_list_links' );
/**
* Returns SVG icon for custom menu icon
*
* @since 1.2.0
*
* @return string
*/
function cptui_menu_icon() {
return 'dashicons-forms';
}
/**
* Return boolean status depending on passed in value.
*
* @since 0.5.0
*
* @param mixed $bool_text text to compare to typical boolean values.
* @return bool Which bool value the passed in value was.
*/
function get_disp_boolean( $bool_text ) {
$bool_text = (string) $bool_text;
if ( empty( $bool_text ) || '0' === $bool_text || 'false' === $bool_text ) {
return false;
}
return true;
}
/**
* Return string versions of boolean values.
*
* @since 0.1.0
*
* @param string $bool_text String boolean value.
* @return string standardized boolean text.
*/
function disp_boolean( $bool_text ) {
$bool_text = (string) $bool_text;
if ( empty( $bool_text ) || '0' === $bool_text || 'false' === $bool_text ) {
return 'false';
}
return 'true';
}
/**
* Display footer links and plugin credits.
*
* @since 0.3.0
*
* @internal
*
* @param string $original Original footer content. Optional. Default empty string.
* @return string $value HTML for footer.
*/
function cptui_footer( $original = '' ) {
$screen = get_current_screen();
if ( ! is_object( $screen ) || 'cptui_main_menu' !== $screen->parent_base ) {
return $original;
}
return sprintf(
// translators: Placeholder will hold the name of the plugin, version of the plugin and a link to WebdevStudios.
esc_attr__( '%1$s version %2$s by %3$s', 'custom-post-type-ui' ),
esc_attr__( 'Custom Post Type UI', 'custom-post-type-ui' ),
CPTUI_VERSION,
'<a href="https://webdevstudios.com" target="_blank" rel="noopener">WebDevStudios</a>'
) . ' - ' .
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
'<a href="http://wordpress.org/support/plugin/custom-post-type-ui" target="_blank" rel="noopener">%s</a>',
esc_attr__( 'Support forums', 'custom-post-type-ui' )
) . ' - ' .
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
'<a href="https://wordpress.org/plugins/custom-post-type-ui/reviews/" target="_blank" rel="noopener">%s</a>',
sprintf(
// translators: Placeholder will hold `<abbr>` tag for CPTUI.
esc_attr__( 'Review %s', 'custom-post-type-ui' ),
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
'<abbr title="%s">%s</abbr>',
esc_attr__( 'Custom Post Type UI', 'custom-post-type-ui' ),
'CPTUI'
)
)
) . ' - ' .
esc_attr__( 'Follow on Twitter:', 'custom-post-type-ui' ) .
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
' %s',
'<a href="https://twitter.com/webdevstudios" target="_blank" rel="noopener">WebDevStudios</a>'
);
}
add_filter( 'admin_footer_text', 'cptui_footer' );
/**
* Conditionally flushes rewrite rules if we have reason to.
*
* @since 1.3.0
*/
function cptui_flush_rewrite_rules() {
if ( wp_doing_ajax() ) {
return;
}
/*
* Wise men say that you should not do flush_rewrite_rules on init or admin_init. Due to the nature of our plugin
* and how new post types or taxonomies can suddenly be introduced, we need to...potentially. For this,
* we rely on a short lived transient. Only 5 minutes life span. If it exists, we do a soft flush before
* deleting the transient to prevent subsequent flushes. The only times the transient gets created, is if
* post types or taxonomies are created, updated, deleted, or imported. Any other time and this condition
* should not be met.
*/
$flush_it = get_transient( 'cptui_flush_rewrite_rules' );
if ( 'true' === $flush_it ) {
flush_rewrite_rules( false );
// So we only run this once.
delete_transient( 'cptui_flush_rewrite_rules' );
}
}
add_action( 'admin_init', 'cptui_flush_rewrite_rules' );
/**
* Return the current action being done within CPTUI context.
*
* @since 1.3.0
*
* @return string Current action being done by CPTUI
*/
function cptui_get_current_action() {
$current_action = '';
if ( ! empty( $_GET ) && isset( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$current_action .= esc_textarea( wp_unslash( $_GET['action'] ) ); // phpcs:ignore
}
return $current_action;
}
/**
* Return an array of all post type slugs from Custom Post Type UI.
*
* @since 1.3.0
*
* @return array CPTUI post type slugs.
*/
function cptui_get_post_type_slugs() {
$post_types = get_option( 'cptui_post_types' );
if ( ! empty( $post_types ) ) {
return array_keys( $post_types );
}
return [];
}
/**
* Return an array of all taxonomy slugs from Custom Post Type UI.
*
* @since 1.3.0
*
* @return array CPTUI taxonomy slugs.
*/
function cptui_get_taxonomy_slugs() {
$taxonomies = get_option( 'cptui_taxonomies' );
if ( ! empty( $taxonomies ) ) {
return array_keys( $taxonomies );
}
return [];
}
/**
* Return the appropriate admin URL depending on our context.
*
* @since 1.3.0
*
* @param string $path URL path.
* @return string
*/
function cptui_admin_url( $path ) {
if ( is_multisite() && is_network_admin() ) {
return network_admin_url( $path );
}
return admin_url( $path );
}
/**
* Construct action tag for `<form>` tag.
*
* @since 1.3.0
*
* @param object|string $ui CPTUI Admin UI instance. Optional. Default empty string.
* @return string
*/
function cptui_get_post_form_action( $ui = '' ) {
/**
* Filters the string to be used in an `action=""` attribute.
*
* @since 1.3.0
*/
return apply_filters( 'cptui_post_form_action', '', $ui );
}
/**
* Display action tag for `<form>` tag.
*
* @since 1.3.0
*
* @param object $ui CPTUI Admin UI instance.
*/
function cptui_post_form_action( $ui ) {
echo esc_attr( cptui_get_post_form_action( $ui ) );
}
/**
* Fetch our CPTUI post types option.
*
* @since 1.3.0
*
* @return mixed
*/
function cptui_get_post_type_data() {
return apply_filters( 'cptui_get_post_type_data', get_option( 'cptui_post_types', [] ), get_current_blog_id() );
}
/**
* Fetch our CPTUI taxonomies option.
*
* @since 1.3.0
*
* @return mixed
*/
function cptui_get_taxonomy_data() {
return apply_filters( 'cptui_get_taxonomy_data', get_option( 'cptui_taxonomies', [] ), get_current_blog_id() );
}
/**
* Checks if a post type is already registered.
*
* @since 1.3.0
*
* @param string $slug Post type slug to check. Optional. Default empty string.
* @param array|string $data Post type data being utilized. Optional.
* @return mixed
*/
function cptui_get_post_type_exists( $slug = '', $data = [] ) {
/**
* Filters the boolean value for if a post type exists for 3rd parties.
*
* @since 1.3.0
*
* @param string $slug Post type slug to check.
* @param array|string $data Post type data being utilized.
*/
return apply_filters( 'cptui_get_post_type_exists', post_type_exists( $slug ), $data );
}
/**
* Checks if a taxonomy is already registered.
*
* @since 1.6.0
*
* @param string $slug Taxonomy slug to check. Optional. Default empty string.
* @param array|string $data Taxonomy data being utilized. Optional.
*
* @return mixed
*/
function cptui_get_taxonomy_exists( $slug = '', $data = [] ) {
/**
* Filters the boolean value for if a taxonomy exists for 3rd parties.
*
* @since 1.6.0
*
* @param string $slug Taxonomy slug to check.
* @param array|string $data Taxonomy data being utilized.
*/
return apply_filters( 'cptui_get_taxonomy_exists', taxonomy_exists( $slug ), $data );
}
/**
* Displays WebDevStudios products in a sidebar on the add/edit screens for post types and taxonomies.
*
* We hope you don't mind.
*
* @since 1.3.0
*
* @internal
*/
function cptui_products_sidebar() {
echo '<div class="wdspromos">';
cptui_newsletter_form();
$ads = cptui_get_ads();
if ( ! empty( $ads ) ) {
foreach ( $ads as $ad ) {
$the_ad = sprintf(
'<img src="%s" alt="%s">',
esc_attr( $ad['image'] ),
esc_attr( $ad['text'] )
);
// Escaping $the_ad breaks the html.
printf(
'<p><a href="%s">%s</a></p>',
esc_url( $ad['url'] ),
$the_ad // phpcs:ignore WordPress.Security.EscapeOutput
);
}
printf(
'<p><a href="%s">%s</a></p>',
'https://pluginize.com/plugins/custom-post-type-ui-extended/ref/pluginizeaff/?campaign=cptui-sidebar-remove',
esc_html__( 'Remove these ads?', 'custom-post-type-ui' )
);
}
echo '</div>';
}
add_action( 'cptui_below_post_type_tab_menu', 'cptui_products_sidebar' );
add_action( 'cptui_below_taxonomy_tab_menu', 'cptui_products_sidebar' );
/**
* Outputs our newsletter signup form.
*
* @since 1.3.4
* @internal
*/
function cptui_newsletter_form() {
?>
<div class="email-octopus-form-wrapper">
<?php
echo sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
'<p><strong>%s</strong></p>',
esc_html__( 'Get email updates from pluginize.com about Custom Post Type UI', 'custom-post-type-ui' )
);
?>
<p class="email-octopus-success-message"></p>
<p class="email-octopus-error-message"></p>
<form method="post" action="https://emailoctopus.com/lists/2039e001-4775-11ea-be00-06b4694bee2a/members/embedded/1.3/add" class="email-octopus-form" data-sitekey="6LdYsmsUAAAAAPXVTt-ovRsPIJ_IVhvYBBhGvRV6">
<div class="email-octopus-form-row">
<?php
echo sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
'<label for="field_0">%s</label>',
esc_html__( 'Email address', 'custom-post-type-ui' )
);
?>
<input id="field_0" name="field_0" type="email" placeholder="email@domain.com" style="max-width:100%;">
</div>
<div class="email-octopus-form-row-hp" aria-hidden="true">
<!-- Do not remove this field, otherwise you risk bot sign-ups -->
<input type="text" name="hp2039e001-4775-11ea-be00-06b4694bee2a" tabindex="-1" autocomplete="nope">
</div>
<div class="email-octopus-form-row-subscribe">
<input type="hidden" name="successRedirectUrl" value="">
<?php
echo sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
'<button type="submit" class="button button-secondary">%s</button>',
esc_html__( 'Subscribe', 'custom-post-type-ui' )
);
?>
</div>
</form>
</div>
<?php
}
/**
* Add our Email Octopus scripts and stylesheet.
*
* @author Scott Anderson <scott.anderson@webdevstudios.com>
* @since NEXT
*/
function enqueue_email_octopus_assets() {
$current_screen = get_current_screen();
if ( ! is_object( $current_screen ) ) {
return;
}
$screens = [
'toplevel_page_cptui_main_menu',
'cpt-ui_page_cptui_manage_post_types',
'cpt-ui_page_cptui_manage_taxonomies',
];
if ( ! in_array( $current_screen->base, $screens, true ) ) {
return;
}
if ( ! has_action( 'cptui_below_post_type_tab_menu' ) || ! has_action( 'cptui_below_taxonomy_tab_menu' ) ) {
return;
}
wp_enqueue_style( 'cptui-emailoctopus', 'https://emailoctopus.com/bundles/emailoctopuslist/css/formEmbed.css' ); // phpcs:ignore
wp_enqueue_script( 'cptui-emailoctopus-js', 'https://emailoctopus.com/bundles/emailoctopuslist/js/1.4/formEmbed.js', [ 'jquery' ], '', true ); // phpcs:ignore
}
add_action( 'admin_enqueue_scripts', 'enqueue_email_octopus_assets' );
/**
* Fetch all set ads to be displayed.
*
* @since 1.3.4
*
* @return array
*/
function cptui_get_ads() {
/**
* Filters the array of ads to iterate over.
*
* Each index in the ads array should have a url index with the url to link to,
* an image index specifying an image location to load from, and a text index used
* for alt attribute text.
*
* @since 1.3.4
*
* @param array $value Array of ads to iterate over. Default empty.
*/
return (array) apply_filters( 'cptui_ads', [] );
}
/**
* Add our default ads to the ads filter.
*
* @since 1.3.4
*
* @internal
*
* @param array $ads Array of ads set so far. Optional.
* @return array $ads Array of newly constructed ads.
*/
function cptui_default_ads( $ads = [] ) {
$ads[] = [
'url' => 'https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=cptui',
'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/cptui-extended.png',
'text' => 'Custom Post Type UI Extended product ad',
];
$ads[] = [
'url' => 'https://pluginize.com/plugins/instago/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=instago',
'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/instago.png',
'text' => 'InstaGo product ad',
];
$ads[] = [
'url' => 'https://pluginize.com/plugins/buddypages/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=buddypages',
'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/buddypages.png',
'text' => 'BuddyPages product ad',
];
$ads[] = [
'url' => 'https://pluginize.com/plugins/wp-search-with-algolia-pro/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=wp-search-with-algolia-pro',
'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/wp-search-with-algolia-pro.png',
'text' => 'WP Search with Algolia Pro product ad',
];
return $ads;
}
add_filter( 'cptui_ads', 'cptui_default_ads' );
/**
* Randomize our array order.
* Preserves CPTUI-Extended as the first index. Self promotion, yo.
*
* @since 1.3.0
*
* @param array $ads Array of ads to show.
* @return array
*/
function cptui_randomize_ads( $ads = [] ) {
$new_order = [];
foreach ( $ads as $key => $ad ) {
if ( false !== strpos( $ad['url'], 'custom-post-type-ui-extended' ) ) {
$new_order[] = $ad;
unset( $ads[ $key ] );
}
}
shuffle( $ads );
return array_merge( $new_order, $ads );
}
add_filter( 'cptui_ads', 'cptui_randomize_ads', 11 );
/**
* Secondary admin notices function for use with admin_notices hook.
*
* Constructs admin notice HTML.
*
* @since 1.4.0
*
* @param string $message Message to use in admin notice. Optional. Default empty string.
* @param bool $success Whether or not a success. Optional. Default true.
* @return mixed
*/
function cptui_admin_notices_helper( $message = '', $success = true ) {
$class = [];
$class[] = $success ? 'updated' : 'error';
$class[] = 'notice is-dismissible';
$messagewrapstart = '<div id="message" class="' . implode( ' ', $class ) . '"><p>';
$messagewrapend = '</p></div>';
$action = '';
/**
* Filters the custom admin notice for CPTUI.
*
* @since 1.0.0
*
* @param string $value Complete HTML output for notice.
* @param string $action Action whose message is being generated.
* @param string $message The message to be displayed.
* @param string $messagewrapstart Beginning wrap HTML.
* @param string $messagewrapend Ending wrap HTML.
*/
return apply_filters( 'cptui_admin_notice', $messagewrapstart . $message . $messagewrapend, $action, $message, $messagewrapstart, $messagewrapend );
}
/**
* Grab post type or taxonomy slug from $_POST global, if available.
*
* @since 1.4.0
*
* @internal
*
* @return string
*/
function cptui_get_object_from_post_global() {
if ( isset( $_POST['cpt_custom_post_type']['name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$type_item = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
if ( $type_item ) {
return sanitize_text_field( $type_item['name'] );
}
}
if ( isset( $_POST['cpt_custom_tax']['name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$tax_item = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
if ( $tax_item ) {
return sanitize_text_field( $tax_item['name'] );
}
}
return esc_html__( 'Object', 'custom-post-type-ui' );
}
/**
* Successful add callback.
*
* @since 1.4.0
*/
function cptui_add_success_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%s has been successfully added', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
)
);
}
/**
* Fail to add callback.
*
* @since 1.4.0
*/
function cptui_add_fail_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%s has failed to be added', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
),
false
);
}
/**
* Successful update callback.
*
* @since 1.4.0
*/
function cptui_update_success_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%s has been successfully updated', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
)
);
}
/**
* Fail to update callback.
*
* @since 1.4.0
*/
function cptui_update_fail_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%s has failed to be updated', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
),
false
);
}
/**
* Successful delete callback.
*
* @since 1.4.0
*/
function cptui_delete_success_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%s has been successfully deleted', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
)
);
}
/**
* Fail to delete callback.
*
* @since 1.4.0
*/
function cptui_delete_fail_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( '%s has failed to be deleted', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
),
false
);
}
/**
* Success to import callback.
*
* @since 1.5.0
*/
function cptui_import_success_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
esc_html__( 'Successfully imported data.', 'custom-post-type-ui' )
);
}
/**
* Failure to import callback.
*
* @since 1.5.0
*/
function cptui_import_fail_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
esc_html__( 'Invalid data provided', 'custom-post-type-ui' ),
false
);
}
/**
* Failure to verify nonce, callback
*
* @since 1.7.4
*/
function cptui_nonce_fail_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
esc_html__( 'Nonce failed verification', 'custom-post-type-ui' ),
false
);
}
/**
* Returns error message for if trying to register existing post type.
*
* @since 1.4.0
*
* @return string
*/
function cptui_slug_matches_post_type() {
return sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Please choose a different post type name. %s is already registered.', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
);
}
/**
* Returns error message for if trying to register existing taxonomy.
*
* @since 1.4.0
*
* @return string
*/
function cptui_slug_matches_taxonomy() {
return sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Please choose a different taxonomy name. %s is already registered.', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
);
}
/**
* Returns error message for if not providing a post type to associate taxonomy to.
*
* @since 1.6.0
*
* @return string
*/
function cptui_empty_cpt_on_taxonomy() {
return esc_html__( 'Please provide a post type to attach to.', 'custom-post-type-ui' );
}
/**
* Returns error message for if trying to register post type with matching page slug.
*
* @since 1.4.0
*
* @return string
*/
function cptui_slug_matches_page() {
$slug = cptui_get_object_from_post_global();
$matched_slug = get_page_by_path(
cptui_get_object_from_post_global()
);
if ( $matched_slug instanceof WP_Post ) {
$slug = sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
'<a href="%s">%s</a>',
get_edit_post_link( $matched_slug->ID ),
cptui_get_object_from_post_global()
);
}
return sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Please choose a different post type name. %s matches an existing page slug, which can cause conflicts.', 'custom-post-type-ui' ),
$slug
);
}
/**
* Returns error message for if trying to use quotes in slugs or rewrite slugs.
*
* @since 1.4.0
*
* @return string
*/
function cptui_slug_has_quotes() {
return sprintf(
esc_html__( 'Please do not use quotes in post type/taxonomy names or rewrite slugs', 'custom-post-type-ui' ),
cptui_get_object_from_post_global()
);
}
/**
* Error admin notice.
*
* @since 1.4.0
*/
function cptui_error_admin_notice() {
echo cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
apply_filters( 'cptui_custom_error_message', '' ),
false
);
}
/**
* Mark site as not a new CPTUI install upon update to 1.5.0
*
* @since 1.5.0
*
* @param object $wp_upgrader WP_Upgrader instance.
* @param array $extras Extra information about performed upgrade.
*/
function cptui_not_new_install( $wp_upgrader, $extras ) {
if ( $wp_upgrader instanceof \Plugin_Upgrader ) {
return;
}
if ( ! array_key_exists( 'plugins', $extras ) || ! is_array( $extras['plugins'] ) ) {
return;
}
// Was CPTUI updated?
if ( ! in_array( 'custom-post-type-ui/custom-post-type-ui.php', $extras['plugins'], true ) ) {
return;
}
// If we are already known as not new, return.
if ( cptui_is_new_install() ) {
return;
}
// We need to mark ourselves as not new.
cptui_set_not_new_install();
}
add_action( 'upgrader_process_complete', 'cptui_not_new_install', 10, 2 );
/**
* Check whether or not we're on a new install.
*
* @since 1.5.0
*
* @return bool
*/
function cptui_is_new_install() {
$new_or_not = true;
$saved = get_option( 'cptui_new_install', '' );
if ( 'false' === $saved ) {
$new_or_not = false;
}
/**
* Filters the new install status.
*
* Offers third parties the ability to override if they choose to.
*
* @since 1.5.0
*
* @param bool $new_or_not Whether or not site is a new install.
*/
return (bool) apply_filters( 'cptui_is_new_install', $new_or_not );
}
/**
* Set our activation status to not new.
*
* @since 1.5.0
*/
function cptui_set_not_new_install() {
update_option( 'cptui_new_install', 'false' );
}
/**
* Returns saved values for single post type from CPTUI settings.
*
* @since 1.5.0
*
* @param string $post_type Post type to retrieve CPTUI object for.
* @return string
*/
function cptui_get_cptui_post_type_object( $post_type = '' ) {
$post_types = get_option( 'cptui_post_types', [] );
if ( is_array( $post_types ) && array_key_exists( $post_type, $post_types ) ) {
return $post_types[ $post_type ];
}
return [];
}
/**
* Returns saved values for single taxonomy from CPTUI settings.
*
* @since 1.5.0
*
* @param string $taxonomy Taxonomy to retrieve CPTUI object for.
* @return string
*/
function cptui_get_cptui_taxonomy_object( $taxonomy = '' ) {
$taxonomies = get_option( 'cptui_taxonomies', [] );
if ( is_array( $taxonomies ) && array_key_exists( $taxonomy, $taxonomies ) ) {
return $taxonomies[ $taxonomy ];
}
return [];
}
/**
* Checks if a requested post type has a custom CPTUI feature supported.
*
* @since 1.5.0
*
* @param string $post_type Post type slug.
* @param string $feature Feature to check for.
* @return bool
*/
function cptui_post_type_supports( $post_type, $feature ) {
$object = cptui_get_cptui_post_type_object( $post_type );
if ( ! empty( $object ) ) {
if ( array_key_exists( $feature, $object ) && ! empty( $object[ $feature ] ) ) {
return true;
}
return false;
}
return false;
}
/**
* Add missing post_format taxonomy support for CPTUI post types.
*
* Addresses bug wih previewing changes for published posts with post types that
* have post-formats support.
*
* @since 1.5.8
*
* @param array $post_types Array of CPTUI post types.
*/
function cptui_published_post_format_fix( $post_types ) {
if ( empty( $post_types ) || ! is_array( $post_types ) ) {
return;
}
foreach ( $post_types as $type ) {
if ( ! is_array( $type['supports'] ) ) {
continue;
}
if ( in_array( 'post-formats', $type['supports'], true ) ) {
add_post_type_support( $type['name'], 'post-formats' );
register_taxonomy_for_object_type( 'post_format', $type['name'] );
}
}
}
add_action( 'cptui_post_register_post_types', 'cptui_published_post_format_fix' );
/**
* Return a ready-to-use admin url for adding a new content type.
*
* @since 1.7.0
*
* @param string $content_type Content type to link to.
* @return string
*/
function cptui_get_add_new_link( $content_type = '' ) {
if ( ! in_array( $content_type, [ 'post_types', 'taxonomies' ], true ) ) {
return cptui_admin_url( 'admin.php?page=cptui_manage_post_types' );
}
return cptui_admin_url( 'admin.php?page=cptui_manage_' . $content_type );
}
<?php
/**
* Custom Post Type UI WP-CLI.
*
* @package CPTUI
* @subpackage WP-CLI
* @author WebDevStudios
* @since 1.6.0
* @license GPL-2.0+
*/
// phpcs:disable WebDevStudios.All.RequireAuthor
/**
* Imports and exports Custom Post Type UI setting data.
*/
class CPTUI_Import_JSON extends WP_CLI_Command {
public $args;
public $assoc_args;
public $type;
public $data = [];
/**
* Imports and parses JSON into CPTUI settings.
*
* ## Options
*
* [--type=<type>]
* : What type of import this is. Available options are `post_type` and `taxonomy`.
*
* [--data-path=<path>]
* : The server path to the file holding JSON data to import. Relative to PWD.
*/
public function import( $args, $assoc_args ) {
$this->args = $args;
$this->assoc_args = $assoc_args;
if ( ! isset( $this->assoc_args['type'] ) ) {
WP_CLI::error( esc_html__( 'Please provide whether you are importing post types or taxonomies', 'custom-post-type-ui' ) );
}
if ( ! isset( $this->assoc_args['data-path'] ) ) {
WP_CLI::error( esc_html__( 'Please provide a path to the file holding your CPTUI JSON data.', 'custom-post-type-ui' ) );
}
$this->type = $assoc_args['type'];
$json = file_get_contents( $this->assoc_args['data-path'] );
if ( empty( $json ) ) {
WP_CLI::error( esc_html__( 'No JSON data found', 'custom-post-type-ui' ) );
}
if ( 'post_type' === $this->type ) {
$this->data['cptui_post_import'] = json_decode( stripslashes_deep( trim( $json ) ), true );
}
if ( 'taxonomy' === $this->type ) {
$this->data['cptui_tax_import'] = json_decode( stripslashes_deep( trim( $json ) ), true );
}
$result = cptui_import_types_taxes_settings( $this->data );
if ( false === $result || 'import_fail' === $result ) {
WP_CLI::error( sprintf( esc_html__( 'An error on import occurred', 'custom-post-type-ui' ) ) );
} else {
WP_CLI::success(
sprintf(
/* translators: Placeholders are just for HTML markup that doesn't need translated */
esc_html__( 'Imported %s successfully', 'custom-post-type-ui' ),
$this->type
)
);
}
}
/**
* Export CPTUI settings to file.
*
* ## Options
*
* [--type=<type>]
* : Which settings to export. Available options are `post_type` and `taxonomy`.
*
* [--dest-path=<path>]
* : The path and file to export to. Relative to PWD.
*/
public function export( $args, $assoc_args ) {
$this->args = $args;
$this->assoc_args = $assoc_args;
if ( ! isset( $this->assoc_args['type'] ) ) {
WP_CLI::error( esc_html__( 'Please provide whether you are exporting your post types or taxonomies', 'custom-post-type-ui' ) );
}
if ( ! isset( $this->assoc_args['dest-path'] ) ) {
WP_CLI::error( esc_html__( 'Please provide a path to export your data to.', 'custom-post-type-ui' ) );
}
$this->type = $assoc_args['type'];
if ( 'post_type' === $this->type ) {
$content = cptui_get_post_type_data();
}
if ( 'taxonomy' === $this->type ) {
$content = cptui_get_taxonomy_data();
}
$content = wp_json_encode( $content );
$result = file_put_contents( $this->assoc_args['dest-path'], $content );
if ( false === $result ) {
WP_CLI::error( esc_html__( 'Error saving data.', 'custom-post-type-ui' ) );
}
WP_CLI::success( esc_html__( 'Successfully saved data to file.', 'custom-post-type-ui' ) );
}
}
WP_CLI::add_command( 'cptui', 'CPTUI_Import_JSON' );
=== Custom Post Type UI ===
Contributors: webdevstudios, pluginize, tw2113, williamsba1
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3084056
Tags: custom post types, post type, taxonomy, content types, CPT, CMS, post, types, custom
Requires at least: 5.9
Tested up to: 6.2.2
Stable tag: 1.13.7
License: GPL-2.0+
Requires PHP: 5.6
Admin UI for creating custom content types like post types and taxonomies
== Description ==
Custom Post Type UI provides an easy to use interface for registering and managing custom post types and taxonomies for your website.
= Custom Post Type UI Extended =
CPTUI helps create custom content types, but displaying that content can be a whole new challenge. We created [Custom Post Type UI Extended](https://pluginize.com/product/custom-post-type-ui-extended/?utm_source=cptui-desription&utm_medium=text&utm_campaign=wporg) to help with displaying your crafted content. [View our Layouts page](https://pluginize.com/cpt-ui-extended-features/?utm_source=cptui-description-examples&utm_medium=text&utm_campaign=wporg) to see available layout examples with Custom Post Type UI Extended.
Beginning with version 1.7.0, Custom Post Type UI Extended has properly moved in to the Block editor experience and is working to get all the layouts available in the new "Custom Post Type UI Block". It's now even easier to start showing your content with the existing and future layouts available with Custom Post Type UI Extended.
[Pluginize](https://pluginize.com/?utm_source=cptui&utm_medium=text&utm_campaign=wporg) was launched in 2016 by [WebDevStudios](https://webdevstudios.com/) to promote, support, and house all of their [WordPress products](https://pluginize.com/shop/?utm_source=cptui-&utm_medium=text&utm_campaign=wporg). Pluginize is not only [creating new products for WordPress, like CPTUI Extended](https://pluginize.com/product/custom-post-type-ui-extended/?utm_source=cptui&utm_medium=text&utm_campaign=wporg), but also provides ongoing support and development for WordPress community favorites like [CMB2](https://wordpress.org/plugins/cmb2/) and more.
= Plugin development =
Custom Post Type UI development is managed on GitHub, with official releases published on WordPress.org. The GitHub repo can be found at [https://github.com/WebDevStudios/custom-post-type-ui](https://github.com/WebDevStudios/custom-post-type-ui). Please use the WordPress.org support tab for potential bugs, issues, or enhancement ideas.
== Screenshots ==
1. Add new post type screen and tab.
2. Add new taxonomy screen and tab.
3. Registered post types and taxonomies from CPTUI
4. Tools screen.
5. Help/support screen.
== Changelog ==
= 1.13.7 - 2023-07-11 =
* Fixed: "themes" marked as reserved taxonomy slug. Causes issues with featured image metabox.
* Fixed: PHP notice around `sort` parameter.
= 1.13.6 - 2023-05-30 =
* Fixed: Prevent PHP errors for dynamic WordPress hooks.
* Fixed: Prevent PHP errors from array_key_exist() checks on non arrays.
* Updated: Removed Maintainn graphic and added WP Search with Algolia Pro graphic.
* Updated: Fixed a lot of text escaping for translation-ready content.
= 1.13.5 - 2023-03-27 =
* Fixed: Security issue in CPTUI Debug Info screen.
* Fixed: Added `empty()` check for `can_export` parameters.
* Updated: Changed textdomain loading from `plugins_loaded` to `init`.
= 1.13.4 - 2022-12-16 =
* Fixed: Character encoding issue on CPTUI setting save in conjunction with PHP8 compatibility.
= 1.13.3 - 2022-12-15 =
* Fixed: Multiple PHP8 compatibility notices and warnings.
* Fixed: "Invalid argument for foreach" based notices around labels.
* Updated: Added taxonomy PHP global sanitization for 3rd party parameters.
= 1.13.2 - 2022-11-29 =
* Fixed: Removed forcing of underscores in place of dashes for taxonomy slugs. Yay!
* Updated: tested up to WP 6.1.1
* Updated: Documentation links in wordpress.org FAQ section.
= 1.13.1 - 2022-09-08 =
* Fixed: Various issues caused by a misplaced output for `ob_get_clean()` outside of function.
= 1.13.0 - 2022-09-07 =
* Added: Notes regarding featured image and post format support also needing `add_theme_support` to work.
* Fixed: Issues around double quotes and JSON export with the post type description field
* Fixed: Issues around HTML markup being removed from post type description field stemming from 1.10.x release
* Fixed: Pluralization issue with our UI for some field labels
* Updated: Code separation and quality cleanup.
* Updated: Plugin branding.
= 1.12.1 - 2022-05-16 =
* Fixed: JSON decoding issues around WP-CLI import.
= 1.12.0 - 2022-05-09 =
* Added: Tested on WordPress 6.0.
* Added: Auto-check, but not force, "page-attributes" when setting a post type as hierarchical.
* Added: "rest_namespace" parameters for both post types and taxonomies.
* Added: "register_meta_box_cb" parameter for post types.
* Fixed: undefined index notices for "can_export".
* Updated: list of reserved taxonomy names with more that are considered reserved.
* Updated: readme descriptions and screenshots.
= 1.11.2 - 2022-03-21 =
* Fixed: Unintended reuse of `$delete_with_user` variable and `can_export` option. Props @bogutskyy
* Fixed: PHP notices around `sort` array index.
= 1.11.1 - 2022-03-18 =
* Fixed: Errors and warnings around array_key_exists() and bool values
= 1.11.0 - 2022-03-17 =
* Added: "sort" argument for taxonomies.
* Added: "can export" argument for post types
* Added: New taxonomy labels from WordPress 5.9
* Added: Custom option to set "Enter title here" value for post types.
* Added: Notes around "exclude from search" argument for post types and taxonomy term archives.
* Added: Notes around taxonomy "hierarchical" option regarding category vs tag behavior.
* Updated: Reserved post type slugs from recent WordPress releases.
* Fixed: PHP warnings around foreach loops in cptui_published_post_format_fix()
== Upgrade Notice ==
= 1.13.7 - 2023-07-11 =
* Fixed: "themes" marked as reserved taxonomy slug. Causes issues with featured image metabox.
* Fixed: PHP notice around `sort` parameter.
= 1.13.6 - 2023-05-30 =
* Fixed: Prevent PHP errors for dynamic WordPress hooks.
* Fixed: Prevent PHP errors from array_key_exist() checks on non arrays.
* Updated: Removed Maintainn graphic and added WP Search with Algolia Pro graphic.
* Updated: Fixed a lot of text escaping for translation-ready content.
= 1.13.5 - 2023-03-27 =
* Fixed: Security issue in CPTUI Debug Info screen.
* Fixed: Added `empty()` check for `can_export` parameters.
* Updated: Changed textdomain loading from `plugins_loaded` to `init`.
= 1.13.4 - 2022-12-16 =
* Fixed: Character encoding issue on CPTUI setting save in conjunction with PHP8 compatibility.
= 1.13.3 - 2022-12-15 =
* Fixed: Multiple PHP8 compatibility notices and warnings.
* Fixed: "Invalid argument for foreach" based notices around labels.
* Updated: Added taxonomy PHP global sanitization for 3rd party parameters.
= 1.13.2 - 2022-11-29 =
* Fixed: Removed forcing of underscores in place of dashes for taxonomy slugs. Yay!
* Updated: tested up to WP 6.1.1
* Updated: Documentation links in wordpress.org FAQ section.
= 1.13.1 - 2022-09-08 =
* Fixed: Various issues caused by a misplaced output for `ob_get_clean()` outside of function.
= 1.13.0 - 2022-09-07 =
* Added: Notes regarding featured image and post format support also needing `add_theme_support` to work.
* Fixed: Issues around double quotes and JSON export with the post type description field
* Fixed: Issues around HTML markup being removed from post type description field stemming from 1.10.x release
* Fixed: Pluralization issue with our UI for some field labels
* Updated: Code separation and quality cleanup.
* Updated: Plugin branding.
= 1.12.1 - 2022-05-16 =
* Fixed: JSON decoding issues around WP-CLI import.
= 1.12.0 - 2022-05-09 =
* Added: Tested on WordPress 6.0.
* Added: Auto-check, but not force, "page-attributes" when setting a post type as hierarchical.
* Added: "rest_namespace" parameters for both post types and taxonomies.
* Added: "register_meta_box_cb" parameter for post types.
* Fixed: undefined index notices for "can_export".
* Updated: list of reserved taxonomy names with more that are considered reserved.
* Updated: readme descriptions and screenshots.
= 1.11.2 - 2022-03-21 =
* Fixed: Unintended reuse of `$delete_with_user` variable and `can_export` option. Props @bogutskyy
* Fixed: PHP notices around `sort` array index.
= 1.11.1 - 2022-03-18 =
* Fixed: Errors and warnings around array_key_exists() and bool values
= 1.11.0 - 2022-03-17 =
* Added: "sort" argument for taxonomies.
* Added: "can export" argument for post types
* Added: New taxonomy labels from WordPress 5.9
* Added: Custom option to set "Enter title here" value for post types.
* Added: Notes around "exclude from search" argument for post types and taxonomy term archives.
* Added: Notes around taxonomy "hierarchical" option regarding category vs tag behavior.
* Updated: Reserved post type slugs from recent WordPress releases.
* Fixed: PHP warnings around foreach loops in cptui_published_post_format_fix()
== Installation ==
= Admin Installer via search =
1. Visit the Add New plugin screen and search for "custom post type ui".
2. Click the "Install Now" button.
3. Activate the plugin.
4. Navigate to the "CPTUI" Menu.
= Admin Installer via zip =
1. Visit the Add New plugin screen and click the "Upload Plugin" button.
2. Click the "Browse..." button and select zip file from your computer.
3. Click "Install Now" button.
4. Once done uploading, activate Custom Post Type UI.
= Manual =
1. Upload the Custom Post Type UI folder to the plugins directory in your WordPress installation.
2. Activate the plugin.
3. Navigate to the "CPTUI" Menu.
That's it! Now you can easily start creating custom post types and taxonomies in WordPress.
== Frequently Asked Questions ==
#### User documentation
Please see https://docs.pluginize.com/tutorials/custom-post-type-ui/