This commit is contained in:
2026-10-06 18:51:23 -06:00
parent 8424dacd03
commit e2c26b7f21
4223 changed files with 737986 additions and 53 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

@@ -0,0 +1,533 @@
/*! jQuery UI - v1.12.1 - 2019-11-24
* http://jqueryui.com
* Includes: core.css, accordion.css, theme.css
* To view and modify this theme, visit http://jqueryui.com/themeroller/?scope=&folderName=base&cornerRadiusShadow=8px&offsetLeftShadow=0px&offsetTopShadow=0px&thicknessShadow=5px&opacityShadow=30&bgImgOpacityShadow=0&bgTextureShadow=flat&bgColorShadow=666666&opacityOverlay=30&bgImgOpacityOverlay=0&bgTextureOverlay=flat&bgColorOverlay=aaaaaa&iconColorError=cc0000&fcError=5f3f3f&borderColorError=f1a899&bgTextureError=flat&bgColorError=fddfdf&iconColorHighlight=777620&fcHighlight=777620&borderColorHighlight=dad55e&bgTextureHighlight=flat&bgColorHighlight=fffa90&iconColorActive=ffffff&fcActive=ffffff&borderColorActive=003eff&bgTextureActive=flat&bgColorActive=007fff&iconColorHover=555555&fcHover=2b2b2b&borderColorHover=cccccc&bgTextureHover=flat&bgColorHover=ededed&iconColorDefault=777777&fcDefault=454545&borderColorDefault=c5c5c5&bgTextureDefault=flat&bgColorDefault=f6f6f6&iconColorContent=444444&fcContent=333333&borderColorContent=dddddd&bgTextureContent=flat&bgColorContent=ffffff&iconColorHeader=444444&fcHeader=333333&borderColorHeader=dddddd&bgTextureHeader=flat&bgColorHeader=e9e9e9&cornerRadius=3px&fwDefault=normal&fsDefault=1em&ffDefault=Arial%2CHelvetica%2Csans-serif
* Copyright jQuery Foundation and other contributors; Licensed MIT */
/* Layout helpers
----------------------------------*/
.ui-helper-hidden {
display: none;
}
.ui-helper-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.ui-helper-reset {
margin: 0;
padding: 0;
border: 0;
outline: 0;
line-height: 1.3;
text-decoration: none;
font-size: 100%;
list-style: none;
}
.ui-helper-clearfix:before,
.ui-helper-clearfix:after {
content: "";
display: table;
border-collapse: collapse;
}
.ui-helper-clearfix:after {
clear: both;
}
.ui-helper-zfix {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
opacity: 0;
filter:Alpha(Opacity=0); /* support: IE8 */
}
.ui-front {
z-index: 100;
}
/* Interaction Cues
----------------------------------*/
.ui-state-disabled {
cursor: default !important;
pointer-events: none;
}
/* Icons
----------------------------------*/
.ui-icon {
display: inline-block;
vertical-align: middle;
margin-top: -.25em;
position: relative;
text-indent: -99999px;
overflow: hidden;
background-repeat: no-repeat;
}
.ui-widget-icon-block {
left: 50%;
margin-left: -8px;
display: block;
}
/* Misc visuals
----------------------------------*/
/* Overlays */
.ui-widget-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.ui-accordion .ui-accordion-header {
display: block;
cursor: pointer;
position: relative;
margin: 2px 0 0 0;
padding: .5em .5em .5em .7em;
font-size: 100%;
}
.ui-accordion .ui-accordion-content {
padding: 0.3em 1.4em;
border-top: 0;
overflow: auto;
}
/* Component containers
----------------------------------*/
.ui-widget {
font-family: Arial,Helvetica,sans-serif;
font-size: 1em;
}
.ui-widget .ui-widget {
font-size: 1em;
}
.ui-widget input,
.ui-widget select,
.ui-widget textarea,
.ui-widget button {
font-family: Arial,Helvetica,sans-serif;
font-size: 1em;
}
.ui-widget.ui-widget-content {
border: 1px solid #c5c5c5;
}
.ui-widget-content {
border: 1px solid #dddddd;
background: #ffffff;
color: #333333;
}
.ui-widget-content a {
color: #333333;
}
.ui-widget-header {
border: 1px solid #dddddd;
background: #e9e9e9;
color: #333333;
font-weight: bold;
}
.ui-widget-header a {
color: #333333;
}
/* Interaction states
----------------------------------*/
.ui-state-default,
.ui-widget-content .ui-state-default,
.ui-widget-header .ui-state-default,
.ui-button,
/* We use html here because we need a greater specificity to make sure disabled
works properly when clicked or hovered */
html .ui-button.ui-state-disabled:hover,
html .ui-button.ui-state-disabled:active {
border: 1px solid #c5c5c5;
background: #f6f6f6;
font-weight: normal;
color: #454545;
}
.ui-state-default a,
.ui-state-default a:link,
.ui-state-default a:visited,
a.ui-button,
a:link.ui-button,
a:visited.ui-button,
.ui-button {
color: #454545;
text-decoration: none;
}
.ui-state-hover,
.ui-widget-content .ui-state-hover,
.ui-widget-header .ui-state-hover,
.ui-state-focus,
.ui-widget-content .ui-state-focus,
.ui-widget-header .ui-state-focus,
.ui-button:hover,
.ui-button:focus {
border: 1px solid #cccccc;
background: #ededed;
font-weight: normal;
color: #2b2b2b;
}
.ui-state-hover a,
.ui-state-hover a:hover,
.ui-state-hover a:link,
.ui-state-hover a:visited,
.ui-state-focus a,
.ui-state-focus a:hover,
.ui-state-focus a:link,
.ui-state-focus a:visited,
a.ui-button:hover,
a.ui-button:focus {
color: #2b2b2b;
text-decoration: none;
}
.ui-visual-focus {
box-shadow: 0 0 3px 1px rgb(94, 158, 214);
}
.ui-state-active,
.ui-widget-content .ui-state-active,
.ui-widget-header .ui-state-active,
a.ui-button:active,
.ui-button:active,
.ui-button.ui-state-active:hover {
font-weight: normal;
background-color: #fff;
}
.ui-icon-background,
.ui-state-active .ui-icon-background {
border: #003eff;
background-color: #ffffff;
}
.ui-state-active a,
.ui-state-active a:link,
.ui-state-active a:visited {
color: #ffffff;
text-decoration: none;
}
/* Interaction Cues
----------------------------------*/
.ui-state-highlight,
.ui-widget-content .ui-state-highlight,
.ui-widget-header .ui-state-highlight {
border: 1px solid #dad55e;
background: #fffa90;
color: #777620;
}
.ui-state-checked {
border: 1px solid #dad55e;
background: #fffa90;
}
.ui-state-highlight a,
.ui-widget-content .ui-state-highlight a,
.ui-widget-header .ui-state-highlight a {
color: #777620;
}
.ui-state-error,
.ui-widget-content .ui-state-error,
.ui-widget-header .ui-state-error {
border: 1px solid #f1a899;
background: #fddfdf;
color: #5f3f3f;
}
.ui-state-error a,
.ui-widget-content .ui-state-error a,
.ui-widget-header .ui-state-error a {
color: #5f3f3f;
}
.ui-state-error-text,
.ui-widget-content .ui-state-error-text,
.ui-widget-header .ui-state-error-text {
color: #5f3f3f;
}
.ui-priority-primary,
.ui-widget-content .ui-priority-primary,
.ui-widget-header .ui-priority-primary {
font-weight: bold;
}
.ui-priority-secondary,
.ui-widget-content .ui-priority-secondary,
.ui-widget-header .ui-priority-secondary {
opacity: .7;
filter:Alpha(Opacity=70); /* support: IE8 */
font-weight: normal;
}
.ui-state-disabled,
.ui-widget-content .ui-state-disabled,
.ui-widget-header .ui-state-disabled {
opacity: .35;
filter:Alpha(Opacity=35); /* support: IE8 */
background-image: none;
}
.ui-state-disabled .ui-icon {
filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */
}
/* Icons
----------------------------------*/
/* states and images */
.ui-icon {
width: 16px;
height: 16px;
}
.ui-icon,
.ui-widget-content .ui-icon {
background-image: url("images/ui-icons_444444_256x240.png");
}
.ui-widget-header .ui-icon {
background-image: url("images/ui-icons_444444_256x240.png");
}
.ui-state-hover .ui-icon,
.ui-state-focus .ui-icon,
.ui-button:hover .ui-icon,
.ui-button:focus .ui-icon {
background-image: url("images/ui-icons_555555_256x240.png");
}
.ui-state-active .ui-icon,
.ui-button:active .ui-icon {
background-image: url("images/ui-icons_ffffff_256x240.png");
}
.ui-state-highlight .ui-icon,
.ui-button .ui-state-highlight.ui-icon {
background-image: url("images/ui-icons_777620_256x240.png");
}
.ui-state-error .ui-icon,
.ui-state-error-text .ui-icon {
background-image: url("images/ui-icons_cc0000_256x240.png");
}
.ui-button .ui-icon {
background-image: url("images/ui-icons_777777_256x240.png");
}
/* positioning */
.ui-icon-blank { background-position: 16px 16px; }
.ui-icon-caret-1-n { background-position: 0 0; }
.ui-icon-caret-1-ne { background-position: -16px 0; }
.ui-icon-caret-1-e { background-position: -32px 0; }
.ui-icon-caret-1-se { background-position: -48px 0; }
.ui-icon-caret-1-s { background-position: -65px 0; }
.ui-icon-caret-1-sw { background-position: -80px 0; }
.ui-icon-caret-1-w { background-position: -96px 0; }
.ui-icon-caret-1-nw { background-position: -112px 0; }
.ui-icon-caret-2-n-s { background-position: -128px 0; }
.ui-icon-caret-2-e-w { background-position: -144px 0; }
.ui-icon-triangle-1-n { background-position: 0 -16px; }
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
.ui-icon-triangle-1-e { background-position: -32px -16px; }
.ui-icon-triangle-1-se { background-position: -48px -16px; }
.ui-icon-triangle-1-s { background-position: -65px -16px; }
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
.ui-icon-triangle-1-w { background-position: -96px -16px; }
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
.ui-icon-arrow-1-n { background-position: 0 -32px; }
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
.ui-icon-arrow-1-e { background-position: -32px -32px; }
.ui-icon-arrow-1-se { background-position: -48px -32px; }
.ui-icon-arrow-1-s { background-position: -65px -32px; }
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
.ui-icon-arrow-1-w { background-position: -96px -32px; }
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
.ui-icon-arrowthick-1-n { background-position: 1px -48px; }
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
.ui-icon-arrow-4 { background-position: 0 -80px; }
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
.ui-icon-extlink { background-position: -32px -80px; }
.ui-icon-newwin { background-position: -48px -80px; }
.ui-icon-refresh { background-position: -64px -80px; }
.ui-icon-shuffle { background-position: -80px -80px; }
.ui-icon-transfer-e-w { background-position: -96px -80px; }
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
.ui-icon-folder-collapsed { background-position: 0 -96px; }
.ui-icon-folder-open { background-position: -16px -96px; }
.ui-icon-document { background-position: -32px -96px; }
.ui-icon-document-b { background-position: -48px -96px; }
.ui-icon-note { background-position: -64px -96px; }
.ui-icon-mail-closed { background-position: -80px -96px; }
.ui-icon-mail-open { background-position: -96px -96px; }
.ui-icon-suitcase { background-position: -112px -96px; }
.ui-icon-comment { background-position: -128px -96px; }
.ui-icon-person { background-position: -144px -96px; }
.ui-icon-print { background-position: -160px -96px; }
.ui-icon-trash { background-position: -176px -96px; }
.ui-icon-locked { background-position: -192px -96px; }
.ui-icon-unlocked { background-position: -208px -96px; }
.ui-icon-bookmark { background-position: -224px -96px; }
.ui-icon-tag { background-position: -240px -96px; }
.ui-icon-home { background-position: 0 -112px; }
.ui-icon-flag { background-position: -16px -112px; }
.ui-icon-calendar { background-position: -32px -112px; }
.ui-icon-cart { background-position: -48px -112px; }
.ui-icon-pencil { background-position: -64px -112px; }
.ui-icon-clock { background-position: -80px -112px; }
.ui-icon-disk { background-position: -96px -112px; }
.ui-icon-calculator { background-position: -112px -112px; }
.ui-icon-zoomin { background-position: -128px -112px; }
.ui-icon-zoomout { background-position: -144px -112px; }
.ui-icon-search { background-position: -160px -112px; }
.ui-icon-wrench { background-position: -176px -112px; }
.ui-icon-gear { background-position: -192px -112px; }
.ui-icon-heart { background-position: -208px -112px; }
.ui-icon-star { background-position: -224px -112px; }
.ui-icon-link { background-position: -240px -112px; }
.ui-icon-cancel { background-position: 0 -128px; }
.ui-icon-plus { background-position: -16px -128px; }
.ui-icon-plusthick { background-position: -32px -128px; }
.ui-icon-minus { background-position: -48px -128px; }
.ui-icon-minusthick { background-position: -64px -128px; }
.ui-icon-close { background-position: -80px -128px; }
.ui-icon-closethick { background-position: -96px -128px; }
.ui-icon-key { background-position: -112px -128px; }
.ui-icon-lightbulb { background-position: -128px -128px; }
.ui-icon-scissors { background-position: -144px -128px; }
.ui-icon-clipboard { background-position: -160px -128px; }
.ui-icon-copy { background-position: -176px -128px; }
.ui-icon-contact { background-position: -192px -128px; }
.ui-icon-image { background-position: -208px -128px; }
.ui-icon-video { background-position: -224px -128px; }
.ui-icon-script { background-position: -240px -128px; }
.ui-icon-alert { background-position: 0 -144px; }
.ui-icon-info { background-position: -16px -144px; }
.ui-icon-notice { background-position: -32px -144px; }
.ui-icon-help { background-position: -48px -144px; }
.ui-icon-check { background-position: -64px -144px; }
.ui-icon-bullet { background-position: -80px -144px; }
.ui-icon-radio-on { background-position: -96px -144px; }
.ui-icon-radio-off { background-position: -112px -144px; }
.ui-icon-pin-w { background-position: -128px -144px; }
.ui-icon-pin-s { background-position: -144px -144px; }
.ui-icon-play { background-position: 0 -160px; }
.ui-icon-pause { background-position: -16px -160px; }
.ui-icon-seek-next { background-position: -32px -160px; }
.ui-icon-seek-prev { background-position: -48px -160px; }
.ui-icon-seek-end { background-position: -64px -160px; }
.ui-icon-seek-start { background-position: -80px -160px; }
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
.ui-icon-seek-first { background-position: -80px -160px; }
.ui-icon-stop { background-position: -96px -160px; }
.ui-icon-eject { background-position: -112px -160px; }
.ui-icon-volume-off { background-position: -128px -160px; }
.ui-icon-volume-on { background-position: -144px -160px; }
.ui-icon-power { background-position: 0 -176px; }
.ui-icon-signal-diag { background-position: -16px -176px; }
.ui-icon-signal { background-position: -32px -176px; }
.ui-icon-battery-0 { background-position: -48px -176px; }
.ui-icon-battery-1 { background-position: -64px -176px; }
.ui-icon-battery-2 { background-position: -80px -176px; }
.ui-icon-battery-3 { background-position: -96px -176px; }
.ui-icon-circle-plus { background-position: 0 -192px; }
.ui-icon-circle-minus { background-position: -16px -192px; }
.ui-icon-circle-close { background-position: -32px -192px; }
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
.ui-icon-circle-zoomin { background-position: -176px -192px; }
.ui-icon-circle-zoomout { background-position: -192px -192px; }
.ui-icon-circle-check { background-position: -208px -192px; }
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
.ui-icon-circlesmall-close { background-position: -32px -208px; }
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
.ui-icon-squaresmall-close { background-position: -80px -208px; }
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
/* Misc visuals
----------------------------------*/
/* Corner radius */
.ui-corner-all,
.ui-corner-top,
.ui-corner-left,
.ui-corner-tl {
border-top-left-radius: 3px;
}
.ui-corner-all,
.ui-corner-top,
.ui-corner-right,
.ui-corner-tr {
border-top-right-radius: 3px;
}
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-left,
.ui-corner-bl {
border-bottom-left-radius: 3px;
}
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-right,
.ui-corner-br {
border-bottom-right-radius: 3px;
}
/* Overlays */
.ui-widget-overlay {
background: #aaaaaa;
opacity: .3;
filter: Alpha(Opacity=30); /* support: IE8 */
}
.ui-widget-shadow {
-webkit-box-shadow: 0px 0px 5px #666666;
box-shadow: 0px 0px 5px #666666;
}
@@ -0,0 +1,53 @@
.wp-faq-schema-item {
border: 1px solid #ccd0d4;
padding: 10px;
margin-bottom: 10px;
}
.wp-faq-schema-item.close {
padding-bottom: 0;
}
.wp-faq-schema-item .wp-faq-schema-header {
border-bottom: 1px solid #ccd0d4;
padding: 10px;
margin: -10px;
margin-bottom: 0;
cursor: pointer;
position: relative;
}
.wp-faq-schema-item.close .wp-faq-schema-header {
border-bottom: none;
}
.wp-faq-schema.close {
display: none;
}
.wp-faq-schema-delete {
float: right;
position: absolute;
top: 0;
right: 0;
height: 100%;
background-color: transparent;
border: none;
color: #888888;
}
.wp-faq-schema-delete:hover {
color: #f74040;
cursor: pointer;
}
.wfs-export-message span {
display: inline-block;
background-color: #fff;
padding: 8px 20px;
margin-top: 10px;
border-left: 2px solid green;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.wfs-export-message span.error {
border-left-color: red;
}
@@ -0,0 +1,323 @@
<?php
/**
* Metabox file
*
* @package WpFaqSchema
*/
namespace WpFaqSchema;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Metabox class
*/
class Metabox {
/**
* Constructor Method for Metabox
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function __construct() {
add_action( 'add_meta_boxes', [ $this, 'metabox_init' ] );
add_action( 'save_post', [ $this, 'save' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'assets' ] );
add_action( 'init', [ $this, 'taxonomy_meta' ], 999 );
}
/**
* Initialize metabox
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function metabox_init() {
$post_types = get_post_types( [
'public' => true,
] );
unset( $post_types['attachment'] );
unset( $post_types['elementor_library'] );
/* translators: icon */
add_meta_box( 'wp-faq-schema', sprintf( __( 'FAQ Schema For Pages And Posts %s', 'wp-faq-schema' ), ' <span class="dashicons dashicons-info" title="' . __( 'To save just update your page, this text saves automatically on page update.', 'wp-faq-schema' ) . '"></span>' ), [ $this, 'view' ], array_keys( $post_types ) );
}
/**
* Metabox view
*
* @param WP_Post $post Post Object.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function view( $post ) {
$faqs = get_post_meta( $post->ID, '_wp_faq_schema', true );
if ( empty( $faqs ) ) {
$faqs = [
[
'q' => '',
'a' => '',
],
];
}
?>
<div class="wp-faq-schema-container">
<input type="hidden" name="wp-faq-schema-nonce" value="<?php echo esc_attr( wp_create_nonce( 'wp-faq-schema' ) ); ?>">
<div class="wp-faq-schema-items">
<?php foreach ( $faqs as $index => $faq ) : ?>
<div class="wp-faq-schema-item">
<div class="wp-faq-schema-header">
<span>
<?php
/* translators: index */
echo esc_html( ! empty( $faq['q'] ) ? $faq['q'] : sprintf( __( 'Question #%s', 'wp-faq-schema' ), $index + 1 ) );
?>
</span>
<button class="wp-faq-schema-delete" type="button" data-confirm="<?php esc_html_e( 'Are you sure you want to delete this question and answer?', 'wp-faq-schema' ); ?>"><span class="dashicons dashicons-trash"></span></button>
</div>
<div class="wp-faq-schema">
<p>
<label for="wp-faq-schema-q-<?php echo esc_attr( $index ); ?>"><?php esc_html_e( 'Question', 'wp-faq-schema' ); ?></label>
<input type="text" id="wp-faq-schema-q-<?php echo esc_attr( $index ); ?>" name="wp-faq-schema[<?php echo esc_attr( $index ); ?>][q]" class="widefat" value="<?php echo esc_attr( ! empty( $faq['q'] ) ? $faq['q'] : '' ); ?>">
</p>
<p>
<label for="wp-faq-schema-a-<?php echo esc_attr( $index ); ?>"><?php esc_html_e( 'Answer', 'wp-faq-schema' ); ?></label>
<textarea name="wp-faq-schema[<?php echo esc_attr( $index ); ?>][a]" id="wp-faq-schema-a-<?php echo esc_attr( $index ); ?>" rows="3" class="widefat"><?php echo esc_html( ! empty( $faq['a'] ) ? $faq['a'] : '' ); ?></textarea>
</p>
</div>
</div>
<?php endforeach; ?>
</div>
<?php /* translators: index */ ?>
<button type="button" class="button button-primary wp-faq-schema-add" data-index="<?php echo count( $faqs ); ?>" data-title="<?php esc_attr_e( 'Question #%s', 'wp-faq-schema' ); ?>">
<?php echo esc_html_e( 'Add Another Question', 'wp-faq-schema' ); ?>
</button>
</div>
<script type="text/html" id="tmpl-faq-schema-form">
<div class="wp-faq-schema-item">
<div class="wp-faq-schema-header">
<span>{TITLE}</span>
<button class="wp-faq-schema-delete" type="button" data-confirm="<?php esc_attr_e( 'Are you sure? You want to delete this.', 'wp-faq-schema' ); ?>"><span class="dashicons dashicons-trash"></span></button>
</div>
<div class="wp-faq-schema">
<p>
<label for="wp-faq-schema-q-{INDEX}"><?php esc_html_e( 'Question', 'wp-faq-schema' ); ?></label>
<input type="text" id="wp-faq-schema-q-{INDEX}" name="wp-faq-schema[{INDEX}][q]" class="widefat">
</p>
<p>
<label for="wp-faq-schema-a-{INDEX}"><?php esc_html_e( 'Answer', 'wp-faq-schema' ); ?></label>
<textarea id="wp-faq-schema-a-{INDEX}" name="wp-faq-schema[{INDEX}][a]" rows="3" class="widefat"></textarea>
</p>
</div>
</div>
</script>
<?php
}
/**
* Save meta values
*
* @param int $post_id Post ID.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function save( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
if ( ! isset( $_POST['wp-faq-schema-nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['wp-faq-schema-nonce'] ), 'wp-faq-schema' ) ) {
return;
}
update_post_meta( $post_id, '_wp_faq_schema', ! isset( $_POST['wp-faq-schema'] ) ? [] : $this->sanitize( $_POST['wp-faq-schema'] ) ); // phpcs:ignore
}
/**
* Metabox assets
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function assets() {
wp_enqueue_style( 'wp-faq-schema-style', WP_FAQ_SCHEMA_URL . '/css/wp-faq-schema.css', false, '1.0.0' );
wp_enqueue_script( 'sweetalert2', WP_FAQ_SCHEMA_URL . '/js/sweetalert2.all.min.js', [ 'jquery' ], '1.0.0', true );
wp_enqueue_script( 'papaparse', WP_FAQ_SCHEMA_URL . '/js/papaparse.min.js', [ 'jquery' ], '1.0.0', true );
wp_enqueue_script( 'wp-faq-schema-scripts', WP_FAQ_SCHEMA_URL . '/js/wp-faq-schema.js', [ 'jquery', 'papaparse', 'sweetalert2' ], '1.0.0', true );
$data = 'var wfs_ajax="' . admin_url( 'admin-ajax.php' ) . '";';
wp_add_inline_script( 'wp-faq-schema-scripts', $data, 'before' );
}
/**
* Sanitize full array
*
* @param array $faqs Array.
*
* @since 1.0.0
* @access public
*
* @return array
*/
public function sanitize( $faqs ) {
$new_faqs = [];
if ( ! empty( $faqs ) && is_array( $faqs ) ) {
foreach ( $faqs as $faq ) {
$new_faq = [];
if ( ! empty( $faq['q'] ) ) {
$new_faq['q'] = sanitize_text_field( $faq['q'] );
}
if ( ! empty( $faq['a'] ) ) {
$new_faq['a'] = wp_kses_post( $faq['a'] );
}
if ( ! empty( $new_faq ) ) {
$new_faqs[] = $new_faq;
}
}
}
return $new_faqs;
}
public function taxonomy_meta() {
$taxonomies = get_taxonomies( ['publicly_queryable' => true] );
$taxonomies = array_keys( $taxonomies );
foreach( $taxonomies as $taxonomy ) {
add_filter( $taxonomy . '_add_form_fields', array( $this, 'tax_meta' ) );
add_filter( $taxonomy . '_edit_form_fields', array( $this, 'tax_meta_edit' ) );
add_action( 'edit_' . $taxonomy, array( $this, 'save_tax_meta' ) );
add_action( 'create_' . $taxonomy, array( $this, 'save_tax_meta' ) );
}
}
public function tax_meta() {
?>
<div class="form-field is-tax">
<?php $this->tax_meta_label(); ?>
<?php $this->tax_meta_view( false ); ?>
</div>
<?php
}
public function tax_meta_edit( $term ) {
?>
<tr class="form-field store-logo-wrap">
<th scope="row">
<?php $this->tax_meta_label(); ?>
</th>
<td>
<div class="is-tax">
<?php $this->tax_meta_view( $term->term_id ); ?>
</div>
</td>
</tr>
<?php
}
public function tax_meta_label() {
?>
<label class="is-tax-label"><?php printf( __( 'FAQ Schema For Pages And Posts %s', 'wp-faq-schema' ), ' <span class="dashicons dashicons-info" title="' . __( 'To save just update your page, this text saves automatically on page update.', 'wp-faq-schema' ) . '"></span>' ) ?></label>
<?php
}
public function tax_meta_view( $term_id ) {
$faqs = $term_id ? get_term_meta( $term_id, '_wp_faq_schema', true ) : '';
if ( empty( $faqs ) ) {
$faqs = [
[
'q' => '',
'a' => '',
],
];
}
?>
<div class="wp-faq-schema-container">
<input type="hidden" name="wp-faq-schema-nonce" value="<?php echo esc_attr( wp_create_nonce( 'wp-faq-schema' ) ); ?>">
<div class="wp-faq-schema-items">
<?php foreach ( $faqs as $index => $faq ) : ?>
<div class="wp-faq-schema-item">
<div class="wp-faq-schema-header">
<span>
<?php
/* translators: index */
echo esc_html( ! empty( $faq['q'] ) ? $faq['q'] : sprintf( __( 'Question #%s', 'wp-faq-schema' ), $index + 1 ) );
?>
</span>
<button class="wp-faq-schema-delete" type="button" data-confirm="<?php esc_html_e( 'Are you sure you want to delete this question and answer?', 'wp-faq-schema' ); ?>"><span class="dashicons dashicons-trash"></span></button>
</div>
<div class="wp-faq-schema">
<p>
<label for="wp-faq-schema-q-<?php echo esc_attr( $index ); ?>"><?php esc_html_e( 'Question', 'wp-faq-schema' ); ?></label>
<input type="text" id="wp-faq-schema-q-<?php echo esc_attr( $index ); ?>" name="wp-faq-schema[<?php echo esc_attr( $index ); ?>][q]" class="widefat" value="<?php echo esc_attr( ! empty( $faq['q'] ) ? $faq['q'] : '' ); ?>">
</p>
<p>
<label for="wp-faq-schema-a-<?php echo esc_attr( $index ); ?>"><?php esc_html_e( 'Answer', 'wp-faq-schema' ); ?></label>
<textarea name="wp-faq-schema[<?php echo esc_attr( $index ); ?>][a]" id="wp-faq-schema-a-<?php echo esc_attr( $index ); ?>" rows="3" class="widefat"><?php echo esc_html( ! empty( $faq['a'] ) ? $faq['a'] : '' ); ?></textarea>
</p>
</div>
</div>
<?php endforeach; ?>
</div>
<?php /* translators: index */ ?>
<button type="button" class="button button-primary wp-faq-schema-add" data-index="<?php echo count( $faqs ); ?>" data-title="<?php esc_attr_e( 'Question #%s', 'wp-faq-schema' ); ?>">
<?php echo esc_html_e( 'Add Another Question', 'wp-faq-schema' ); ?>
</button>
</div>
<script type="text/html" id="tmpl-faq-schema-form">
<div class="wp-faq-schema-item">
<div class="wp-faq-schema-header">
<span>{TITLE}</span>
<button class="wp-faq-schema-delete" type="button" data-confirm="<?php esc_attr_e( 'Are you sure? You want to delete this.', 'wp-faq-schema' ); ?>"><span class="dashicons dashicons-trash"></span></button>
</div>
<div class="wp-faq-schema">
<p>
<label for="wp-faq-schema-q-{INDEX}"><?php esc_html_e( 'Question', 'wp-faq-schema' ); ?></label>
<input type="text" id="wp-faq-schema-q-{INDEX}" name="wp-faq-schema[{INDEX}][q]" class="widefat">
</p>
<p>
<label for="wp-faq-schema-a-{INDEX}"><?php esc_html_e( 'Answer', 'wp-faq-schema' ); ?></label>
<textarea id="wp-faq-schema-a-{INDEX}" name="wp-faq-schema[{INDEX}][a]" rows="3" class="widefat"></textarea>
</p>
</div>
</div>
</script>
<?php
}
public function save_tax_meta( $term_id ) {
if ( ! isset( $_POST['wp-faq-schema-nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['wp-faq-schema-nonce'] ), 'wp-faq-schema' ) ) {
return;
}
update_term_meta( $term_id, '_wp_faq_schema', ! isset( $_POST['wp-faq-schema'] ) ? [] : $this->sanitize( $_POST['wp-faq-schema'] ) ); // phpcs:ignore
}
}
@@ -0,0 +1,226 @@
<?php
/**
* Option Page file
*
* @package WpFaqSchema
*/
namespace WpFaqSchema;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Option Page class
*/
class Option_Page {
/**
* Constructor Method for Option Page
*
* @since 2.0.0
* @access public
*
* @return void
*/
public function __construct() {
add_action( 'admin_menu', [ $this, 'register' ] );
add_action( 'wp_ajax_wfs_export', [ $this, 'export' ] );
add_action( 'wp_ajax_wfs_import', [ $this, 'import' ] );
}
/**
* Register Option Page
*
* @since 2.0.0
* @access public
*
* @return void
*/
public function register() {
add_options_page( __( 'FAQ Schema For Pages And Posts', 'wp-faq-schema' ), __( 'FAQ Schema For Pages And Posts', 'wp-faq-schema' ), 'manage_options', 'wp-faq-schema', [ $this, 'view' ] );
}
/**
* Option Page view
*
* @since 2.0.0
* @access public
*
* @return void
*/
public function view() {
?>
<div class="wrap">
<h1><?php esc_html_e( 'FAQ Schema For Pages And Posts Settings', 'wp-faq-schema' ); ?></h1>
<h2><?php esc_html_e( 'How the plugin works step by step:', 'wp-faq-schema' ); ?></h2>
<p><a href="https://robotzebra.agency" target="_blank"><?php esc_html_e( 'Find out how the plugin works', 'wp-faq-schema' ); ?></a></p>
<iframe width="560" height="315" src="https://www.youtube.com/watch?v=pRhXbu24lsQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<ol>
<li><?php esc_html_e( 'Just to insert JSON-LD in a given page, go to that page/post and you’ll find new fields at the bottom the editor in the WP backend.', 'wp-faq-schema' ); ?></li>
<li><?php esc_html_e( 'If you’d like to also display your Questions and Answers via a FAQ, use the shortcode. Title defines the heading above the FAQs. If you’d like to use an accordion, add accordion=1 as in the example. Remove that part not to use an accordion and just show all FAQs open (ie. [wp-faq-schema title="Car FAQs" accordion=1] )', 'wp-faq-schema' ); ?></li>
<li><?php esc_html_e( 'If you’d like to mass edit, use the Export section to export all of the pages and posts with their ids - and then edit the file and import it back. Note: For multiple FAQs for same post add more row at CSV file with same ID and title.', 'wp-faq-schema' ); ?></li>
</ol>
<h2><?php esc_html_e( 'How to make FAQ display on the front end:', 'wp-faq-schema' ); ?></h2>
<p><?php echo wp_kses( __( 'Add the shortcode inside of the page or post content to display the FAQ. The shortcode tag is <code>wp-faq-schema</code>. It will take <code>title</code> and <code>accordion</code> attributes.', 'wp-faq-schema' ), [ 'code' => [] ] ); ?></p>
<p><strong><?php esc_html_e( 'Example below:', 'wp-faq-schema' ); ?></strong></p>
<p><code>[wp-faq-schema]</code> - <?php esc_html_e( 'This code will only show FAQs of that page or post.', 'wp-faq-schema' ); ?></p>
<p><code>[wp-faq-schema title="Car FAQs"]</code> - <?php esc_html_e( 'This code will show FAQs with "Car FAQs" title.', 'wp-faq-schema' ); ?></p>
<p><code>[wp-faq-schema accordion=1]</code> - <?php esc_html_e( 'This code will show FAQs as accordion.', 'wp-faq-schema' ); ?></p>
<p><code>[wp-faq-schema title="Car FAQs" accordion=1]</code> - <?php esc_html_e( 'This code will show FAQs as accordion with "Car FAQs" title.', 'wp-faq-schema' ); ?></p>
<h2><?php esc_html_e( 'Export for editing on multiple pages', 'wp-faq-schema' ) ?></h2>
<p><?php esc_html_e( 'Export a CSV with your posts and pages to edit the CSV with your FAQs and re-upload it back to import all of them automatically.', 'wp-faq-schema' ); ?></p>
<form method="post">
<input type="hidden" id="wfs-nonce" name="wfs_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wfs_nonce' ) ); ?>">
<table class="form-table">
<tbody>
<tr>
<th>
<label for="wp-faq-schema-export"><?php esc_html_e( 'Export', 'wp-faq-schema' ); ?></label>
</th>
<td>
<button class="button button-primary" type="button" id="wp-faq-schema-export"><?php esc_html_e( 'Export as .csv', 'wp-faq-schema' ); ?></button>
<div class="wfs-export-message" id="export-message"></div>
</td>
</tr>
<tr>
<th>
<label for="wp-faq-schema-import-file"><?php esc_html_e( 'Import', 'wp-faq-schema' ); ?></label>
</th>
<td>
<input type="file" id="wp-faq-schema-import-file">
<button class="button button-primary" type="button" id="wp-faq-schema-import"><?php esc_html_e( 'Import', 'wp-faq-schema' ); ?></button>
<div class="wfs-export-message" id="import-message"></div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<?php
}
/**
* Export FAQs
*
* @since 2.0.0
* @access public
*
* @return void
*/
public function export() {
if ( ! isset( $_POST['wfs_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['wfs_nonce'] ), 'wfs_nonce' ) ) {
wp_send_json_error( __( 'Unauthorized access!', 'wp-faq-schema' ) );
}
$posts = get_posts(
[
'post_type' => [ 'post', 'page', 'avada_portfolio' ],
'posts_per_page' => -1,
'post_status' => [ 'publish', 'pending', 'draft', 'private', 'future' ],
]
);
$faqs = [];
foreach ( $posts as $post ) {
$faq_items = get_post_meta( $post->ID, '_wp_faq_schema', true );
if ( ! empty( $faq_items ) ) {
foreach ( $faq_items as $faq_item ) {
$faqs[] = [
$post->ID,
$post->post_title,
$faq_item['q'],
$faq_item['a'],
];
}
} else {
$faqs[] = [
$post->ID,
$post->post_title,
'',
'',
];
}
}
$output = fopen( 'php://output', 'w' ) or wp_send_json_error( __( 'Unable to export as .csv file!', 'wp-faq-schema' ) );
fputcsv( $output, [ 'id', 'title', 'question', 'answer' ] );
foreach ( $faqs as $faq ) {
fputcsv( $output, $faq );
}
fclose( $output );
die();
}
/**
* Import FAQs
*
* @since 2.0.0
* @access public
*
* @return void
*/
public function import() {
if ( ! isset( $_POST['wfs_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['wfs_nonce'] ), 'wfs_nonce' ) ) {
wp_send_json_error( __( 'Unauthorized access!', 'wp-faq-schema' ) );
}
$items = ! empty( $_POST['items'] ) ? $_POST['items'] : [];
if ( empty( $items ) || ! is_array( $_POST['items'] ) ) {
wp_send_json_error( __( 'Empty csv file.', 'wp-faq-schema' ) );
}
$items_to_import = [];
foreach ( $items as $item ) {
if ( empty( $item[0] ) ) {
continue;
}
$id = (int) $item[0];
if ( empty( $items_to_import[ $id ] ) ) {
$items_to_import[ $id ] = [
'title' => $item[1],
'faqs' => [],
];
}
$items_to_import[ $id ]['faqs'][] = [
'q' => $item[2],
'a' => $item[3],
];
}
foreach ( $items_to_import as $post_id => $item_to_import ) {
$this->import_faq( $post_id, $item_to_import );
}
wp_send_json_success( __( 'All FAQs has been imported. Enjoy!', 'wp-faq-schema' ) );
}
/**
* Import Single Page/Post FAQs
*
* @since 2.0.0
* @access public
*
* @param int $post_id Post ID.
* @param array $post_data Post Data to import.
* @return bool
*/
public function import_faq( $post_id, $post_data ) {
$post = get_post( $post_id );
if ( is_null( $post ) || empty( $post_data['faqs'] ) ) {
return false;
}
return update_post_meta( $post_id, '_wp_faq_schema', $post_data['faqs'] );
}
}
@@ -0,0 +1,257 @@
<?php
/**
* Plugin file
*
* @package WpFaqSchema
*/
namespace WpFaqSchema;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Plugin class
*/
class Plugin {
/**
* Instance.
*
* Holds the plugin instance.
*
* @since 1.0.0
* @access public
* @static
*
* @var Plugin
*/
public static $instance = null;
/**
* Clone.
*
* Disable class cloning and throw an error on object clone.
*
* The whole idea of the singleton design pattern is that there is a single
* object. Therefore, we don't want the object to be cloned.
*
* @access public
* @since 1.0.0
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'wp-faq-schema' ), '1.0.0' );
}
/**
* Wakeup.
*
* Disable unserializing of the class.
*
* @access public
* @since 1.0.0
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'wp-faq-schema' ), '1.0.0' );
}
/**
* Instance.
*
* Ensures only one instance of the plugin class is loaded or can be loaded.
*
* @since 1.0.0
* @access public
* @static
*
* @return Plugin An instance of the class.
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor Method for plugin
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function __construct() {
$this->includes();
$this->init();
add_action( 'wp_head', [ $this, 'print_schema' ] );
add_filter( 'init', [ $this, 'shortcode' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'frontend_assets' ] );
add_filter( 'plugin_row_meta', [ $this, 'plugin_links' ], 10, 2 );
}
/**
* Include all files
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function includes() {
require_once WP_FAQ_SCHEMA_PATH . 'includes/class-option-page.php';
require_once WP_FAQ_SCHEMA_PATH . 'includes/class-metabox.php';
}
/**
* Initialize
*
* Initialize some classes which is not require hook.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function init() {
new Metabox();
new Option_Page();
}
/**
* Print FAQ schema at Header
*
* @return void
*/
public function print_schema() {
$faqs = get_post_meta( get_the_ID(), '_wp_faq_schema', true );
if ( ! is_singular() && ! is_tax() && ! is_category() && ! is_tag() ) {
return;
}
if ( is_tax() || is_category() || is_tag() ) {
$term = get_queried_object();
$faqs = get_term_meta( $term->term_id, '_wp_faq_schema', true );
}
if ( empty( $faqs ) ) {
return;
}
$schema_array = [
'@context' => 'https://schema.org',
'@type' => 'FAQPage',
'mainEntity' => [],
];
if ( ! empty( $faqs ) ) {
foreach ( $faqs as $faq ) {
$schema_array['mainEntity'][] = [
'@type' => 'Question',
'name' => $faq['q'],
'acceptedAnswer' => [
'@type' => 'Answer',
'text' => $faq['a'],
],
];
}
}
?>
<script type="application/ld+json">
<?php echo wp_json_encode( $schema_array ); ?>
</script>
<?php
}
/**
* Shortcodes
*
* @since 2.0.0
* @access public
*
* @return void
*/
public function shortcode() {
add_shortcode( 'wp-faq-schema', [ $this, 'shortcode_view' ] );
}
/**
* Shortcode View
*
* @since 2.0.0
* @access public
*
* @param array $atts Shortcode Atts.
*
* @return string
*/
public function shortcode_view( $atts ) {
$atts = shortcode_atts(
array(
'accordion' => 0,
'title' => '',
),
$atts
);
$faqs = get_post_meta( get_the_ID(), '_wp_faq_schema', true );
if ( empty( $faqs ) ) {
return '';
}
$is_accordion = isset( $atts['accordion'] ) ? intval( $atts['accordion'] ) : 0;
$wrap_class = [ 'wp-faq-schema-wrap' ];
if ( 1 === $is_accordion ) {
$wrap_class[] = 'wp-faq-schema-accordion';
}
ob_start();
?>
<div class="<?php echo esc_attr( implode( ' ', $wrap_class ) ); ?>">
<?php if ( ! empty( $atts['title'] ) ) : ?>
<h2><?php echo esc_html( $atts['title'] ); ?></h2>
<?php endif; ?>
<div class="wp-faq-schema-items">
<?php foreach ( $faqs as $faq ) : ?>
<h3><?php echo esc_html( $faq['q'] ); ?></h3>
<div class="">
<?php echo wp_kses_post( wpautop( $faq['a'] ) ); ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php
$html = ob_get_clean();
return $html;
}
/**
* Frontend assets
*
* @since 2.0.0
* @access public
*
* @return void
*/
public function frontend_assets() {
wp_enqueue_style( 'wp-faq-schema-jquery-ui', WP_FAQ_SCHEMA_URL . '/css/jquery-ui.css', [], '2.0.0' );
wp_enqueue_script( 'wp-faq-schema-frontend', WP_FAQ_SCHEMA_URL . '/js/frontend.js', [ 'jquery', 'jquery-ui-accordion' ], '2.0.0', true );
}
public function plugin_links( $plugin_meta, $plugin_file ) {
if ( 'faq-schema-for-pages-and-posts/wp-faq-schema.php' === $plugin_file ) {
$plugin_meta[] = '<a href="https://robotzebra.agency/" target="_blank">Support</a>';
}
return $plugin_meta;
}
}
Plugin::instance();
@@ -0,0 +1,11 @@
/**
* JS frontend file
*
* @package WpFaqSchema
*/
( function( $ ) {
$( '.wp-faq-schema-accordion .wp-faq-schema-items' ).accordion( {
heightStyle: 'content',
} );
} )( jQuery );
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,174 @@
/**
* JS file
*
* @package WpFaqSchema
*/
( function( $ ) {
$( '.wp-faq-schema-items' ).on( 'click', '.wp-faq-schema-header', function( e ) {
e.preventDefault();
$( this ).parent().toggleClass( 'close' );
$( this ).next().toggleClass( 'close' );
} );
$( '.wp-faq-schema-items' ).on( 'click', '.wp-faq-schema-delete', function( e ) {
e.preventDefault();
e.stopPropagation();
if ( confirm( $( this ).data( 'confirm' ) ) ) {
$( this ).parents( '.wp-faq-schema-item' ).remove();
}
} );
$( '.wp-faq-schema-add' ).on( 'click', function() {
var index = $( this ).data( 'index' ),
title = $( this ).data( 'title' ),
cont = $( this ).prev(),
tmpl = $( '#tmpl-faq-schema-form' ).html();
tmpl = tmpl.replace( '{TITLE}', title.replace( '%s', parseInt( index ) + 1 ) );
tmpl = tmpl.replace( /\{INDEX\}/g, index );
cont.append( tmpl );
$( this ).data( 'index', parseInt( index ) + 1 );
} );
var timeOutTime = null;
$( '#wp-faq-schema-export' ).on( 'click', function( e ) {
e.preventDefault();
$( '#wp-faq-schema-import' ).prop( 'disabled', true );
$( '#wp-faq-schema-export' ).prop( 'disabled', true );
$( '#wp-faq-schema-import-file' ).prop( 'disabled', true );
clearTimeout( timeOutTime );
$( '#export-message' ).html( '' );
var data = {
action: 'wfs_export',
wfs_nonce: $( '#wfs-nonce' ).val(),
};
$.post( wfs_ajax, data, function( res ) {
if ( typeof res.success !== 'undefined' && ! res.success ) {
$( '#export-message' ).append( $( '<span class="error">' + res.data + '</span>' ) );
timeOutTime = setTimeout( function() {
$( '#export-message' ).html( '' );
}, 5 * 1000 );
return;
}
var byteNumbers = new Uint8Array( res.length );
for (var i = 0; i < res.length; i++) {
byteNumbers[i] = res.charCodeAt(i);
}
var blob = new Blob( [ byteNumbers ], { type: 'text/csv' } );
var uri = URL.createObjectURL( blob );
// Construct the <a> element
var link = document.createElement( 'a' );
link.download = 'wp-faq-schema_' + Date.now().toString(36) + '.csv';
link.href = uri;
document.body.appendChild( link );
link.click();
// Cleanup the DOM
document.body.removeChild( link );
delete link;
} ).always( function() {
$( '#wp-faq-schema-import' ).prop( 'disabled', false );
$( '#wp-faq-schema-export' ).prop( 'disabled', false );
$( '#wp-faq-schema-import-file' ).prop( 'disabled', false );
} );
} );
$( '#wp-faq-schema-import' ).on( 'click', function( e ) {
e.preventDefault();
$( '#wp-faq-schema-import' ).prop( 'disabled', true );
$( '#wp-faq-schema-export' ).prop( 'disabled', true );
$( '#wp-faq-schema-import-file' ).prop( 'disabled', true );
clearTimeout( timeOutTime );
$( '#import-message' ).html( '' );
$( '#export-message' ).html( '' );
var file = document.getElementById("wp-faq-schema-import-file").files[0];
if ( file ) {
var reader = new FileReader();
reader.readAsText(file, 'UTF-8');
reader.onload = function (evt) {
var data = Papa.parse( evt.target.result );
var csvData = [];
data.data.forEach( function( item, i ) {
if ( item.length > 3 && i > 0 ) {
csvData.push( item );
}
} );
$.post( wfs_ajax, {
action: 'wfs_import',
items: csvData,
wfs_nonce: $( '#wfs-nonce' ).val(),
}, function( res ) {
if ( res.success ) {
$( '#import-message' ).append( $( '<span>' + res.data + '</span>' ) );
timeOutTime = setTimeout( function() {
$( '#import-message' ).html( '' );
}, 5 * 1000 );
} else {
$( '#import-message' ).append( $( '<span class="error">' + res.data + '</span>' ) );
timeOutTime = setTimeout( function() {
$( '#import-message' ).html( '' );
}, 5 * 1000 );
}
} ).always( function() {
$( '#wp-faq-schema-import' ).prop( 'disabled', false );
$( '#wp-faq-schema-export' ).prop( 'disabled', false );
$( '#wp-faq-schema-import-file' ).prop( 'disabled', false );
} );
}
reader.onerror = function (evt) {
$( '#import-message' ).append( $( '<span class="error">There is no valid file.</span>' ) );
timeOutTime = setTimeout( function() {
$( '#import-message' ).html( '' );
}, 5 * 1000 );
$( '#wp-faq-schema-import' ).prop( 'disabled', false );
$( '#wp-faq-schema-export' ).prop( 'disabled', false );
$( '#wp-faq-schema-import-file' ).prop( 'disabled', false );
}
} else {
$( '#import-message' ).append( $( '<span class="error">There is no valid file.</span>' ) );
timeOutTime = setTimeout( function() {
$( '#import-message' ).html( '' );
}, 5 * 1000 );
$( '#wp-faq-schema-import' ).prop( 'disabled', false );
$( '#wp-faq-schema-export' ).prop( 'disabled', false );
$( '#wp-faq-schema-import-file' ).prop( 'disabled', false );
}
} );
$( '[data-slug="faq-schema-for-pages-and-posts"] .row-actions .deactivate > a' ).on( 'click', function( e ) {
e.preventDefault();
Swal.fire( {
// title: 'Error!',
html: 'Visit <a href="https://www.onlinemarketinggurus.com.au/faq-schema-plugin">https://www.onlinemarketinggurus.com.au/faq-schema-plugin</a> to let us know if the plugin doesn\'t contain functionality that you\'re after or if something wasn\'t working, we appreciate your support.',
icon: 'info',
confirmButtonText: 'Get support',
footer: '<a href="'+$(this).attr('href')+'">Skip & Deactivate</a>'
} ).then( function( result ) {
if ( result.value ) {
var link = $( '<a href="https://www.onlinemarketinggurus.com.au/faq-schema-plugin" target="_blank"/>' )
$( 'body' ).append( link );
link[0].click();
}
} );
} );
} )( jQuery );
@@ -0,0 +1,157 @@
# Copyright (C) 2019 Krystian Szastok (SEO Consultant)
# This file is distributed under the same license as the FAQ Schema For Pages And Posts plugin.
msgid ""
msgstr ""
"Project-Id-Version: FAQ Schema For Pages And Posts 2.0.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/faq-schema-for-pages-and-posts\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2019-11-25T14:49:58+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.2.0\n"
"X-Domain: wp-faq-schema\n"
#. Plugin Name of the plugin
#: includes/class-option-page.php:41
msgid "FAQ Schema For Pages And Posts"
msgstr ""
#. Plugin URI of the plugin
msgid "https://krystianszastok.co.uk/wp-faq-schema-plugin"
msgstr ""
#. Description of the plugin
msgid "To get started with FAQ Schema go to one of your pages or posts and at the bottom you'll find new fields for adding FAQ Schema. Simply save the page to see them come through in the code in the HEAD."
msgstr ""
#. Author of the plugin
msgid "Krystian Szastok (SEO Consultant)"
msgstr ""
#. Author URI of the plugin
msgid "https://krystianszastok.co.uk/"
msgstr ""
#. translators: icon
#: includes/class-metabox.php:42
msgid "FAQ Schema For Pages And Posts %s"
msgstr ""
#. translators: icon
#: includes/class-metabox.php:42
msgid "To save just update your page, this text saves automatically on page update."
msgstr ""
#. translators: index
#: includes/class-metabox.php:77
#: includes/class-metabox.php:96
msgid "Question #%s"
msgstr ""
#: includes/class-metabox.php:80
msgid "Are you sure you want to delete this question and answer?"
msgstr ""
#: includes/class-metabox.php:84
#: includes/class-metabox.php:108
msgid "Question"
msgstr ""
#: includes/class-metabox.php:88
#: includes/class-metabox.php:112
msgid "Answer"
msgstr ""
#: includes/class-metabox.php:97
msgid "Add Another Question"
msgstr ""
#: includes/class-metabox.php:104
msgid "Are you sure? You want to delete this."
msgstr ""
#: includes/class-option-page.php:55
msgid "FAQ Schema For Pages And Posts Settings"
msgstr ""
#: includes/class-option-page.php:63
msgid "Export"
msgstr ""
#: includes/class-option-page.php:66
msgid "Export as .csv"
msgstr ""
#: includes/class-option-page.php:72
#: includes/class-option-page.php:76
msgid "Import"
msgstr ""
#: includes/class-option-page.php:83
msgid "How to make FAQ display on the front end:"
msgstr ""
#: includes/class-option-page.php:84
msgid "Add the shortcode inside of the page or post content to display the FAQ. The shortcode tag is <code>wp-faq-schema</code>. It will take <code>title</code> and <code>accordion</code> attributes."
msgstr ""
#: includes/class-option-page.php:85
msgid "Example below:"
msgstr ""
#: includes/class-option-page.php:86
msgid "This code will only show FAQs of that page or post."
msgstr ""
#: includes/class-option-page.php:87
msgid "This code will show FAQs with \"Car FAQs\" title."
msgstr ""
#: includes/class-option-page.php:88
msgid "This code will show FAQs as accordion."
msgstr ""
#: includes/class-option-page.php:89
msgid "This code will show FAQs as accordion with \"Car FAQs\" title."
msgstr ""
#: includes/class-option-page.php:91
msgid "How the plugin works step by step:"
msgstr ""
#: includes/class-option-page.php:93
msgid "Just to insert JSON-LD in a given page, go to that page/post and you’ll find new fields at the bottom the editor in the WP backend."
msgstr ""
#: includes/class-option-page.php:94
msgid "If you’d like to also display your Questions and Answers via a FAQ, use the shortcode. Title defines the heading above the FAQs. If you’d like to use an accordion, add accordion=1 as in the example. Remove that part not to use an accordion and just show all FAQs open (ie. [wp-faq-schema title=\"Car FAQs\" accordion=1] )"
msgstr ""
#: includes/class-option-page.php:95
msgid "If you’d like to mass edit, use the Export section to export all of the pages and posts with their ids - and then edit the file and import it back. Note: For multiple FAQs for same post add more row at CSV file with same ID and title."
msgstr ""
#: includes/class-option-page.php:112
#: includes/class-option-page.php:168
msgid "Unauthorized access!"
msgstr ""
#: includes/class-option-page.php:146
msgid "Unable to export as .csv file!"
msgstr ""
#: includes/class-option-page.php:174
msgid "Empty csv file."
msgstr ""
#: includes/class-option-page.php:200
msgid "All FAQs has been imported. Enjoy!"
msgstr ""
#: includes/class-plugin.php:44
#: includes/class-plugin.php:57
msgid "Something went wrong."
msgstr ""
@@ -0,0 +1,91 @@
=== FAQ Schema For Pages And Posts ===
Contributors: krystianszastok
Donate link: https://krystianszastok.co.uk/
Tags: SEO, JSON-LD, rich snippets, schema, schema.org, structured data
Requires at least: 4.6
Tested up to: 5.9
Stable tag: 2.4.0
Requires PHP: 5.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
== Description ==
FAQ Schema For Pages And Posts by [Krystian Szastok](https://krystianszastok.co.uk/) Founder of [RobotZebra](https://robotzebra.agency/) - a London based SEO agency, allows you to turn questions and answers on your page (your mini FAQ sections) into JSON-LD code on the fly.
The idea is to add as much meaning as possible into your pages so that Google can understand them better.
You can simply copy and paste as you edit your WordPress page/post into the plugin, as it appears at the bottom of the editor. Once you’ve saved the page, the JSON-LD schema will be present in the HEAD of your page/post — and voila, you’re on your way to a making a great impact across rankings.
If you’re looking for a tutorial, check out our comprehensive video [on YouTube here.](https://www.youtube.com/watch?v=pRhXbu24lsQ).
== Features ==
* Add JSON-LD schema easily to HEAD of any page or post
* Build on-page accordion FAQs
* Mass export to edit multiple page FAQs from a spreadsheet and reimport back in
* Simple copy and paste possible as editor present within a page/post
* Have a chance to gain more visibility on Google’s search result pages
* Secure and sanitised
== Installation ==
1. Upload the wp-faq-schema-for-pages-and-posts folder to the /wp-content/plugins/directory
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Edit your page or post to see the fields for Q&A at the end of them
4. Add in questions and answers and update the post.
== Using the plugin ==
Just to insert JSON-LD in a given page, go to that page/post and you’ll find new fields at the bottom the editor in the WP backend.
If you’d like to also display your Questions and Answers via a FAQ, use the shortcode. Title defines the heading above the FAQs. If you’d like to use an accordion, add accordion=1 as in the example. Remove that part not to use an accordion and just show all FAQs open (ie. [wp-faq-schema title=”Car FAQs” accordion=1] )
If you’d like to mass edit, use the Export section to export all of the pages and posts with their ids – and then edit the file and import it back. Note: For multiple FAQs for same post add more row at CSV file with same ID and title.
Add the shortcode inside of the page or post content to display the FAQ. The shortcode tag is wp-faq-schema. It will take title and accordion attributes.
== Example below: ==
[wp-faq-schema] – This code will only show FAQs of that page or post.
[wp-faq-schema title=”Car FAQs”] – This code will show FAQs with “Car FAQs” title.
[wp-faq-schema accordion=1] – This code will show FAQs as accordion.
[wp-faq-schema title=”Car FAQs” accordion=1] – This code will show FAQs as accordion with “Car FAQs” title.
== Frequently Asked Questions ==
= What is FAQ Schema? =
The FAQPage structured data helps Google understand that the page contains some FAQ (Frequently Asked Questions).
= Why should I use FAQ Schema? =
The FAQPage structured data helps Google understand that the page contains valuable information, in the form of commonly asked questions and answers. This allows Google to deliver more detailed answers on SERPs.
= When should I use FAQ Schema? =
You should use the FAQ Schema on pages that contain questions and answers to do with a given product, service or page information.
= When shouldn't I use FAQ Schema? =
It shouldn’t be used on pages that allow users to submit answers and questions.
= Where to find support for this plugin? =
Ask questions here in the support section.
== Screenshots ==
1. Simple backend panel at the end of each page or post, allowing for unique FAQ schema to be added, saves on page update.
2. Front end output in the source code, validates perfectly with Google's tester.
== Changelog ==
= 1.0.0 =
* Initial release
= 2.0.0 =
* Added export and import, FAQ within the page and lots more!
= 2.2.0 =
* Added ability to add links within the code
= 2.3.0 =
* Added ability to deploy Schema on all types of custom pages, categories etc
= 2.4.0 =
* Updated the descritions and tested with latest Wordpress
@@ -0,0 +1,40 @@
<?php
/**
* Plugin Name: FAQ Schema For Pages And Posts
* Plugin URI: https://www.onlinemarketinggurus.com.au/faq-schema-plugin
* Description: To get started with FAQ Schema go to one of your pages or posts and at the bottom you'll find new fields for adding FAQ Schema. Simply save the page to see them come through in the code in the HEAD.
* Author: Krystian Szastok (SEO Consultant)
* Version: 2.3.0
* Author URI: https://krystianszastok.co.uk/
* Text Domain: wp-faq-schema
* Domain Path: /languages/
* License: GPLv2 or later
*
* @package WpFaqSchema
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'WP_FAQ_SCHEMA_PATH', plugin_dir_path( __FILE__ ) );
define( 'WP_FAQ_SCHEMA_URL', plugin_dir_url( __FILE__ ) );
add_action( 'plugins_loaded', 'wp_faq_schema_load_plugin_textdomain' );
/**
* Load WP FAQ Schema textdomain.
*
* Load gettext translate for WP FAQ Schema text domain.
*
* @since 1.0.0
*
* @return void
*/
function wp_faq_schema_load_plugin_textdomain() {
load_plugin_textdomain( 'wp-faq-schema', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
// Require the main Plugin class.
require WP_FAQ_SCHEMA_PATH . 'includes/class-plugin.php';