diff --git a/assets/css/admin-icon.css b/assets/css/admin-icon.css index 57dfbd4..94c4607 100644 --- a/assets/css/admin-icon.css +++ b/assets/css/admin-icon.css @@ -1,9 +1,11 @@ .dashicons-sermon-manager:before { - font-family: "SermonManager"; - content: "\e900"; } + font-family: "SermonManager"; + content: "\e900"; +} @font-face { - font-family: SermonManager; - src: url(../fonts/Sermon-Manager.ttf); } + font-family: SermonManager; + src: url(../fonts/Sermon-Manager.ttf); +} /*# sourceMappingURL=admin-icon.css.map */ diff --git a/assets/css/admin-icon.css.map b/assets/css/admin-icon.css.map index 4fa13d9..0750a7d 100644 --- a/assets/css/admin-icon.css.map +++ b/assets/css/admin-icon.css.map @@ -1,7 +1,9 @@ { -"version": 3, -"mappings": "AAAA,gCAAiC;EAC/B,WAAW,EAAE,eAAe;EAC5B,OAAO,EAAE,OAAO;;AAGlB,UAGC;EAFC,WAAW,EAAE,aAAa;EAC1B,GAAG,EAAE,gCAAgC", -"sources": ["admin-icon.scss"], -"names": [], -"file": "admin-icon.css" + "version": 3, + "mappings": "AAAA,gCAAiC;EAC/B,WAAW,EAAE,eAAe;EAC5B,OAAO,EAAE,OAAO;;AAGlB,UAGC;EAFC,WAAW,EAAE,aAAa;EAC1B,GAAG,EAAE,gCAAgC", + "sources": [ + "admin-icon.scss" + ], + "names": [], + "file": "admin-icon.css" } \ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css new file mode 100644 index 0000000..a3ef80f --- /dev/null +++ b/assets/css/admin.css @@ -0,0 +1,122 @@ +body.edit-php.post-type-wpfc_sermon .fixed .column-preacher, body.edit-php.post-type-wpfc_sermon .fixed .column-preached { + width: 10%; } +body.edit-php.post-type-wpfc_sermon .fixed .column-series, body.edit-php.post-type-wpfc_sermon .fixed .column-topics { + width: 15%; } +body.edit-php.post-type-wpfc_sermon .fixed .column-views { + width: 7%; } + +body.wpfc_sermon_page_sm-settings .wp-heading-inline { + margin-bottom: 5px; } +body.wpfc_sermon_page_sm-settings .settings-main { + display: flex; + margin-top: 5px; } +body.wpfc_sermon_page_sm-settings .settings-content { + width: 100%; } + body.wpfc_sermon_page_sm-settings .settings-content #mainform { + border: 1px solid #e8e8e8; } + body.wpfc_sermon_page_sm-settings .settings-content span.description { + display: block; + margin-top: 5px; } + body.wpfc_sermon_page_sm-settings .settings-content input[type=text], body.wpfc_sermon_page_sm-settings .settings-content input[type=email] { + width: 100%; + max-width: 400px; } + body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper { + background: white; + padding: 0; + border-bottom: 1px solid #e8e8e8; } + body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab { + float: none; + border: none; + margin: 0; + padding: 20px 20px; + display: inline-block; + background: none; + font-weight: normal; + color: #666; + font-size: 13px; } + body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:hover, body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:active, body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:focus { + border-bottom: 2px solid #ccc; + outline: none; + box-shadow: none; } + body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active, body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:focus, body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:focus:active, body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:hover { + border-bottom: 2px solid #4abcf0; } + body.wpfc_sermon_page_sm-settings .settings-content .inside { + padding: .2rem 1rem .01rem 1rem; + background: white; } +body.wpfc_sermon_page_sm-settings .settings-side { + width: 30%; + max-width: 300px; + margin-left: 1rem; } + body.wpfc_sermon_page_sm-settings .settings-side .sm-box h3 { + margin-left: .8rem; } + body.wpfc_sermon_page_sm-settings .settings-side .sm-box .description { + text-align: center; + font-size: 0.85em; + padding: 0.4rem 0 0; } + body.wpfc_sermon_page_sm-settings .settings-side .sm-box ol { + list-style-type: circle; } + +body.wpfc_sermon_page_sm-import-export .wp-list-table { + overflow: hidden; + height: 100%; } +body.wpfc_sermon_page_sm-import-export .plugin-card { + position: relative; } + body.wpfc_sermon_page_sm-import-export .plugin-card > h2 { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + z-index: 1; + color: #4a4a4a !important; + margin: 0; + font-size: 1.7rem; + font-weight: 100; + letter-spacing: 2px; + font-family: 'Roboto', sans-serif; + text-transform: uppercase; + opacity: 0; + transition: opacity .2s; + cursor: default; } + body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:before { + content: ""; + background: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 10px, rgba(0, 0, 0, 0.1) 10px, rgba(0, 0, 0, 0.1) 20px); + width: 100%; + height: 100%; + position: absolute; + left: 0; + top: 0; + z-index: 1; } + body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:hover > h2 { + opacity: 1; } + body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:hover .plugin-card-top { + -webkit-filter: blur(1px); + filter: blur(1px); } + body.wpfc_sermon_page_sm-import-export .plugin-card.not-available * { + color: #ccc; } + body.wpfc_sermon_page_sm-import-export .plugin-card.not-available .plugin-icon { + filter: opacity(0.2); } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top { + padding: 0; } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top:hover .import-note { + display: block; } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-note { + display: none; + color: rgba(0, 0, 0, 0.5); } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .name { + margin-top: 20px; } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .desc, body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .name { + margin-left: 185px; } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .action-links { + top: 0; } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .plugin-icon { + font-size: 5rem; + color: #656565; + left: 0; + top: 0; + height: 168px; + width: 168px; + margin: -20px 20px 0 0; } + body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .plugin-icon.dashicons { + margin-top: 1rem; } + +/*# sourceMappingURL=admin.css.map */ diff --git a/assets/css/admin.css.map b/assets/css/admin.css.map new file mode 100644 index 0000000..2b0dc6e --- /dev/null +++ b/assets/css/admin.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AACE,wHAAmC;EACjC,KAAK,EAAE,GAAG;AAGZ,oHAA+B;EAC7B,KAAK,EAAE,GAAG;AAGZ,wDAAc;EACZ,KAAK,EAAE,EAAE;;ACVb,oDAAmB;EACjB,aAAa,EAAE,GAAG;AAGpB,gDAAe;EACb,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,GAAG;AAGjB,mDAAkB;EAChB,KAAK,EAAE,IAAI;EAEX,6DAAU;IACR,MAAM,EAAE,iBAAiB;EAG3B,oEAAiB;IACf,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,GAAG;EAGjB,2IAAoC;IAClC,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,KAAK;EAGlB,uEAAoB;IAClB,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,CAAC;IACV,aAAa,EAAE,iBAAiB;IAEhC,gFAAS;MACP,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,IAAI;MACZ,MAAM,EAAE,CAAC;MACT,OAAO,EAAE,SAAS;MAClB,OAAO,EAAE,YAAY;MACrB,UAAU,EAAE,IAAI;MAChB,WAAW,EAAE,MAAM;MACnB,KAAK,EAAE,IAAI;MACX,SAAS,EAAE,IAAI;MAEf,uQAA2B;QACzB,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;IAIpB,2XAA4F;MAC1F,aAAa,EAAE,iBAAiB;EAIpC,2DAAQ;IACN,OAAO,EAAE,sBAAsB;IAC/B,UAAU,EAAE,KAAK;AAIrB,gDAAe;EACb,KAAK,EAAE,GAAG;EACV,SAAS,EAAE,KAAK;EAChB,WAAW,EAAE,IAAI;EAGf,2DAAG;IACD,WAAW,EAAE,KAAK;EAGpB,qEAAa;IACX,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE,UACX;EAEA,2DAAG;IACD,eAAe,EAAE,MAAM;;AC7E7B,qDAAe;EACb,QAAQ,EAAE,MAAM;EAChB,MAAM,EAAE,IAAI;AAGd,mDAAa;EACX,QAAQ,EAAE,QAAQ;EAElB,wDAAK;IACH,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,SAAS,EAAE,qBAAqB;IAChC,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,kBAAkB;IACzB,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,GAAG;IAChB,cAAc,EAAE,GAAG;IACnB,WAAW,EAAE,oBAAoB;IACjC,cAAc,EAAE,SAAS;IACzB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,WAAW;IACvB,MAAM,EAAE,OAAO;EAIf,wEAAS;IACP,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,iIAAiI;IAC7I,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,CAAC;EAIV,4EAAK;IACH,OAAO,EAAE,CAAC;EAGZ,wFAAiB;IACf,cAAc,EAAE,SAAS;IACzB,MAAM,EAAE,SAAS;EAIrB,mEAAE;IACA,KAAK,EAAE,IAAI;EAGb,8EAAa;IACX,MAAM,EAAE,YAAY;EAIxB,oEAAiB;IACf,OAAO,EAAE,CAAC;IAEV,uFAAqB;MACnB,OAAO,EAAE,KAAK;IAGhB,iFAAa;MACX,OAAO,EAAE,IAAI;MACb,KAAK,EAAE,kBAAkB;IAG3B,0EAAM;MACJ,UAAU,EAAE,IAAI;IAGlB,sJAAa;MACX,WAAW,EAAE,KAAK;IAGpB,kFAAc;MACZ,GAAG,EAAE,CAAC;IAGR,iFAAa;MACX,SAAS,EAAE,IAAI;MACf,KAAK,EAAE,OAAO;MACd,IAAI,EAAE,CAAC;MACP,GAAG,EAAE,CAAC;MACN,MAAM,EAAE,KAAK;MACb,KAAK,EAAE,KAAK;MACZ,MAAM,EAAE,cAAc;MAEtB,2FAAY;QACV,UAAU,EAAE,IAAI", +"sources": ["all-sermons.scss","settings.scss","import-export.scss"], +"names": [], +"file": "admin.css" +} \ No newline at end of file diff --git a/assets/css/admin.scss b/assets/css/admin.scss new file mode 100644 index 0000000..68df6f4 --- /dev/null +++ b/assets/css/admin.scss @@ -0,0 +1,14 @@ +// all sermons page +body.edit-php.post-type-wpfc_sermon { + @import 'all-sermons'; +} + +// settings page +body.wpfc_sermon_page_sm-settings { + @import 'settings'; +} + +// import export page +body.wpfc_sermon_page_sm-import-export { + @import 'import-export'; +} \ No newline at end of file diff --git a/assets/css/all-sermons.css b/assets/css/all-sermons.css new file mode 100644 index 0000000..b784737 --- /dev/null +++ b/assets/css/all-sermons.css @@ -0,0 +1,8 @@ +.fixed .column-preacher, .fixed .column-preached { + width: 10%; } +.fixed .column-series, .fixed .column-topics { + width: 15%; } +.fixed .column-views { + width: 7%; } + +/*# sourceMappingURL=all-sermons.css.map */ diff --git a/assets/css/all-sermons.css.map b/assets/css/all-sermons.css.map new file mode 100644 index 0000000..c3345b9 --- /dev/null +++ b/assets/css/all-sermons.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AACE,gDAAmC;EACjC,KAAK,EAAE,GAAG;AAGZ,4CAA+B;EAC7B,KAAK,EAAE,GAAG;AAGZ,oBAAc;EACZ,KAAK,EAAE,EAAE", +"sources": ["all-sermons.scss"], +"names": [], +"file": "all-sermons.css" +} \ No newline at end of file diff --git a/assets/css/all-sermons.scss b/assets/css/all-sermons.scss new file mode 100644 index 0000000..77279ed --- /dev/null +++ b/assets/css/all-sermons.scss @@ -0,0 +1,13 @@ +.fixed { + .column-preacher, .column-preached { + width: 10%; + } + + .column-series, .column-topics { + width: 15%; + } + + .column-views { + width: 7%; + } +} \ No newline at end of file diff --git a/assets/css/error-recovery.css b/assets/css/error-recovery.css index a0e0508..3bee22a 100644 --- a/assets/css/error-recovery.css +++ b/assets/css/error-recovery.css @@ -1,112 +1,137 @@ #sm-fatal-error-notice.loading { - position: relative; } - #sm-fatal-error-notice.loading #sm-curtain { + position: relative; +} + +#sm-fatal-error-notice.loading #sm-curtain { width: 100%; height: 100%; background: #ffffff; - opacity: .7; } - #sm-fatal-error-notice.loading #sm-spinner { - opacity: 1; } + opacity: .7; +} + +#sm-fatal-error-notice.loading #sm-spinner { + opacity: 1; +} #sm-curtain { - position: absolute; - top: 0; - left: 0; - opacity: 0; - background: transparent; - transition: opacity .5s; } - #sm-curtain.dialog { + position: absolute; + top: 0; + left: 0; + opacity: 0; + background: transparent; + transition: opacity .5s; +} + +#sm-curtain.dialog { transition: none; position: fixed; z-index: 99999; background: #fff; opacity: .8; width: 100%; - height: 100%; } + height: 100%; +} #sm-spinner { - z-index: 10; - position: absolute; - top: 50%; - transform: translate(-50%, -50%); - left: 50%; - opacity: 0; - transition: opacity 1s; } + z-index: 10; + position: absolute; + top: 50%; + transform: translate(-50%, -50%); + left: 50%; + opacity: 0; + transition: opacity 1s; +} #sm-disable-recovery-notice { - color: #e29300; } - #sm-disable-recovery-notice > a { - color: #a26300; } + color: #e29300; +} + +#sm-disable-recovery-notice > a { + color: #a26300; +} #sm-error { - background-color: #01354e; - color: #ffffff; - padding: .5rem; } + background-color: #01354e; + color: #ffffff; + padding: .5rem; +} .ui-dialog { - box-shadow: 0 -2px 25px 0 rgba(0, 0, 0, 0.15), 0 13px 25px 0 rgba(0, 0, 0, 0.3); - background-color: #FFFFFF; - margin: 0 auto; - width: auto; - height: auto; - border-radius: 2px 2px 0 0; - padding: 21px 24px 12px; - z-index: 100000; } + box-shadow: 0 -2px 25px 0 rgba(0, 0, 0, 0.15), 0 13px 25px 0 rgba(0, 0, 0, 0.3); + background-color: #FFFFFF; + margin: 0 auto; + width: auto; + height: auto; + border-radius: 2px 2px 0 0; + padding: 21px 24px 12px; + z-index: 100000; +} .ui-dialog-titlebar { - font-family: 'Roboto', sans-serif; - font-weight: 500; - font-size: 20px; - color: rgba(0, 0, 0, 0.8); - line-height: 24px; - text-align: left; - letter-spacing: 0.03px; } + font-family: 'Roboto', sans-serif; + font-weight: 500; + font-size: 20px; + color: rgba(0, 0, 0, 0.8); + line-height: 24px; + text-align: left; + letter-spacing: 0.03px; +} .ui-dialog-content { - font-size: 13px; - color: rgba(0, 0, 0, 0.5); - line-height: 24px; - text-align: left; - letter-spacing: 0.03px; - padding: 14px 0 0; } - .ui-dialog-content textarea, .ui-dialog-content input[type="email"] { - width: 100%; } + font-size: 13px; + color: rgba(0, 0, 0, 0.5); + line-height: 24px; + text-align: left; + letter-spacing: 0.03px; + padding: 14px 0 0; +} + +.ui-dialog-content textarea, .ui-dialog-content input[type="email"] { + width: 100%; +} .ui-dialog-titlebar-close { - display: none; } + display: none; +} .ui-dialog-buttonpane { - width: auto; - height: 48px; - background-color: #FFFFFF; - text-align: right; - border-radius: 0 0 2px 2px; - padding: 8px 0 0 16px; } + width: auto; + height: 48px; + background-color: #FFFFFF; + text-align: right; + border-radius: 0 0 2px 2px; + padding: 8px 0 0 16px; +} .ui-dialog-buttonset > button { - display: inline-block; - height: 36px; - background-color: rgba(9, 9, 9, 0); - font-weight: 500; - font-size: 16px; - color: rgba(33, 150, 243, 0.9); - line-height: 36px; - text-align: center; - letter-spacing: 0.4px; - padding: 0 8px; - margin: 6px 4px; - text-transform: uppercase; - outline: none; - border: none; - cursor: pointer; - transition: all 0.2s ease; } - .ui-dialog-buttonset > button:last-child { - margin-right: 0; } + display: inline-block; + height: 36px; + background-color: rgba(9, 9, 9, 0); + font-weight: 500; + font-size: 16px; + color: rgba(33, 150, 243, 0.9); + line-height: 36px; + text-align: center; + letter-spacing: 0.4px; + padding: 0 8px; + margin: 6px 4px; + text-transform: uppercase; + outline: none; + border: none; + cursor: pointer; + transition: all 0.2s ease; +} + +.ui-dialog-buttonset > button:last-child { + margin-right: 0; +} .ui-dialog-buttonset > button:hover { - background-color: rgba(99, 99, 99, 0.2); } + background-color: rgba(99, 99, 99, 0.2); +} .ui-dialog-buttonset > button:active { - background-color: rgba(99, 99, 99, 0.4); } + background-color: rgba(99, 99, 99, 0.4); +} /*# sourceMappingURL=error-recovery.css.map */ diff --git a/assets/css/error-recovery.css.map b/assets/css/error-recovery.css.map index d2b0bb1..76e881f 100644 --- a/assets/css/error-recovery.css.map +++ b/assets/css/error-recovery.css.map @@ -1,7 +1,9 @@ { -"version": 3, -"mappings": "AAAA,8BAA+B;EAC7B,QAAQ,EAAE,QAAQ;EAElB,0CAAY;IACV,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE,OAAO;IACnB,OAAO,EAAE,EAAE;EAGb,0CAAY;IACV,OAAO,EAAE,CAAC;;AAId,WAAY;EACV,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,CAAC;EACP,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,WAAW;EACvB,UAAU,EAAE,WAAW;EAEvB,kBAAS;IACP,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;;AAIhB,WAAY;EACV,OAAO,EAAE,EAAE;EACX,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,GAAG;EACR,SAAS,EAAE,qBAAqB;EAChC,IAAI,EAAE,GAAG;EACT,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,UAAU;;AAGxB,2BAA4B;EAC1B,KAAK,EAAE,OAAO;EAEd,+BAAI;IACF,KAAK,EAAE,OAAO;;AAIlB,SAAU;EACR,gBAAgB,EAAE,OAAO;EACzB,KAAK,EAAE,OAAO;EACd,OAAO,EAAE,KAAK;;AAGhB,UAAW;EACT,UAAU,EAAE,mEAAmE;EAC/E,gBAAgB,EAAE,OAAO;EACzB,MAAM,EAAE,MAAM;EACd,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,aAAa,EAAE,WAAW;EAC1B,OAAO,EAAE,cAAc;EACvB,OAAO,EAAE,MAAM;;AAGjB,mBAAoB;EAClB,WAAW,EAAE,oBAAoB;EACjC,WAAW,EAAE,GAAG;EAChB,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,kBAAiB;EACxB,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,IAAI;EAChB,cAAc,EAAE,MAAM;;AAGxB,kBAAmB;EACjB,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,kBAAiB;EACxB,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,IAAI;EAChB,cAAc,EAAE,MAAM;EACtB,OAAO,EAAE,QAAQ;EAEjB,mEAA8B;IAC5B,KAAK,EAAE,IAAI;;AAIf,yBAA0B;EACxB,OAAO,EAAE,IAAI;;AAGf,qBAAsB;EACpB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,gBAAgB,EAAE,OAAO;EACzB,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,WAAW;EAC1B,OAAO,EAAE,YAAY;;AAGvB,6BAA8B;EAC5B,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,IAAI;EACZ,gBAAgB,EAAE,gBAAgB;EAClC,WAAW,EAAE,GAAG;EAChB,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,uBAAuB;EAC9B,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,MAAM;EAClB,cAAc,EAAE,KAAK;EACrB,OAAO,EAAE,KAAK;EACd,MAAM,EAAE,OAAO;EACf,cAAc,EAAE,SAAS;EACzB,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,IAAI;EACZ,MAAM,EAAE,OAAO;EACf,UAAU,EAAE,aAAa;EAEzB,wCAAa;IACX,YAAY,EAAE,CAAC;;AAInB,mCAAoC;EAClC,gBAAgB,EAAE,qBAAqB;;AAGzC,oCAAqC;EACnC,gBAAgB,EAAE,qBAAqB", -"sources": ["error-recovery.scss"], -"names": [], -"file": "error-recovery.css" + "version": 3, + "mappings": "AAAA,8BAA+B;EAC7B,QAAQ,EAAE,QAAQ;EAElB,0CAAY;IACV,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE,OAAO;IACnB,OAAO,EAAE,EAAE;EAGb,0CAAY;IACV,OAAO,EAAE,CAAC;;AAId,WAAY;EACV,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,CAAC;EACP,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,WAAW;EACvB,UAAU,EAAE,WAAW;EAEvB,kBAAS;IACP,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;;AAIhB,WAAY;EACV,OAAO,EAAE,EAAE;EACX,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,GAAG;EACR,SAAS,EAAE,qBAAqB;EAChC,IAAI,EAAE,GAAG;EACT,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,UAAU;;AAGxB,2BAA4B;EAC1B,KAAK,EAAE,OAAO;EAEd,+BAAI;IACF,KAAK,EAAE,OAAO;;AAIlB,SAAU;EACR,gBAAgB,EAAE,OAAO;EACzB,KAAK,EAAE,OAAO;EACd,OAAO,EAAE,KAAK;;AAGhB,UAAW;EACT,UAAU,EAAE,mEAAmE;EAC/E,gBAAgB,EAAE,OAAO;EACzB,MAAM,EAAE,MAAM;EACd,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,aAAa,EAAE,WAAW;EAC1B,OAAO,EAAE,cAAc;EACvB,OAAO,EAAE,MAAM;;AAGjB,mBAAoB;EAClB,WAAW,EAAE,oBAAoB;EACjC,WAAW,EAAE,GAAG;EAChB,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,kBAAiB;EACxB,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,IAAI;EAChB,cAAc,EAAE,MAAM;;AAGxB,kBAAmB;EACjB,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,kBAAiB;EACxB,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,IAAI;EAChB,cAAc,EAAE,MAAM;EACtB,OAAO,EAAE,QAAQ;EAEjB,mEAA8B;IAC5B,KAAK,EAAE,IAAI;;AAIf,yBAA0B;EACxB,OAAO,EAAE,IAAI;;AAGf,qBAAsB;EACpB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,gBAAgB,EAAE,OAAO;EACzB,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,WAAW;EAC1B,OAAO,EAAE,YAAY;;AAGvB,6BAA8B;EAC5B,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,IAAI;EACZ,gBAAgB,EAAE,gBAAgB;EAClC,WAAW,EAAE,GAAG;EAChB,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,uBAAuB;EAC9B,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,MAAM;EAClB,cAAc,EAAE,KAAK;EACrB,OAAO,EAAE,KAAK;EACd,MAAM,EAAE,OAAO;EACf,cAAc,EAAE,SAAS;EACzB,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,IAAI;EACZ,MAAM,EAAE,OAAO;EACf,UAAU,EAAE,aAAa;EAEzB,wCAAa;IACX,YAAY,EAAE,CAAC;;AAInB,mCAAoC;EAClC,gBAAgB,EAAE,qBAAqB;;AAGzC,oCAAqC;EACnC,gBAAgB,EAAE,qBAAqB", + "sources": [ + "error-recovery.scss" + ], + "names": [], + "file": "error-recovery.css" } \ No newline at end of file diff --git a/assets/css/import-export.css b/assets/css/import-export.css new file mode 100644 index 0000000..c5b1a80 --- /dev/null +++ b/assets/css/import-export.css @@ -0,0 +1,15 @@ +.plugin-icon { + font-size: 5rem; + color: #656565; + margin-top: 1rem; } + +.column-description ul { + list-style: initial !important; + margin-top: 0; + margin-left: 1.5rem; } + +.wp-list-table { + overflow: hidden; + height: 100%; } + +/*# sourceMappingURL=import-export.css.map */ diff --git a/assets/css/import-export.css.map b/assets/css/import-export.css.map new file mode 100644 index 0000000..daa43c5 --- /dev/null +++ b/assets/css/import-export.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,YAAa;EACX,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,OAAO;EACd,UAAU,EAAE,IAAI;;AAGlB,sBAAuB;EACrB,UAAU,EAAE,kBAAkB;EAC9B,UAAU,EAAE,CAAC;EACb,WAAW,EAAE,MAAM;;AAGrB,cAAe;EACb,QAAQ,EAAE,MAAM;EAChB,MAAM,EAAE,IAAI", +"sources": ["import-export.scss"], +"names": [], +"file": "import-export.css" +} \ No newline at end of file diff --git a/assets/css/import-export.scss b/assets/css/import-export.scss new file mode 100644 index 0000000..ccb936c --- /dev/null +++ b/assets/css/import-export.scss @@ -0,0 +1,97 @@ +.wp-list-table { + overflow: hidden; + height: 100%; +} + +.plugin-card { + position: relative; + + > h2 { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + z-index: 1; + color: #4a4a4a !important; + margin: 0; + font-size: 1.7rem; + font-weight: 100; + letter-spacing: 2px; + font-family: 'Roboto', sans-serif; + text-transform: uppercase; + opacity: 0; + transition: opacity .2s; + cursor: default; + } + + &.not-available { + &:before { + content: ""; + background: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 10px, rgba(0, 0, 0, 0.1) 10px, rgba(0, 0, 0, 0.1) 20px); + width: 100%; + height: 100%; + position: absolute; + left: 0; + top: 0; + z-index: 1; + } + + &:hover { + > h2 { + opacity: 1; + } + + .plugin-card-top { + -webkit-filter: blur(1px); + filter: blur(1px); + } + } + + * { + color: #ccc; + } + + .plugin-icon { + filter: opacity(0.2); + } + } + + .plugin-card-top { + padding: 0; + + &:hover .import-note { + display: block; + } + + .import-note { + display: none; + color: rgba(0, 0, 0, 0.5); + } + + .name { + margin-top: 20px; + } + + .desc, .name { + margin-left: 185px; + } + + .action-links { + top: 0; + } + + .plugin-icon { + font-size: 5rem; + color: #656565; + left: 0; + top: 0; + height: 168px; + width: 168px; + margin: -20px 20px 0 0; + + &.dashicons { + margin-top: 1rem; + } + } + } +} \ No newline at end of file diff --git a/assets/css/settings.css b/assets/css/settings.css new file mode 100644 index 0000000..3a38011 --- /dev/null +++ b/assets/css/settings.css @@ -0,0 +1,3 @@ + + +/*# sourceMappingURL=settings.css.map */ diff --git a/assets/css/settings.css.map b/assets/css/settings.css.map new file mode 100644 index 0000000..052989f --- /dev/null +++ b/assets/css/settings.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "", +"sources": [], +"names": [], +"file": "settings.css" +} \ No newline at end of file diff --git a/assets/css/settings.scss b/assets/css/settings.scss new file mode 100644 index 0000000..a46a38e --- /dev/null +++ b/assets/css/settings.scss @@ -0,0 +1,81 @@ +.wp-heading-inline { + margin-bottom: 5px; +} + +.settings-main { + display: flex; + margin-top: 5px; +} + +.settings-content { + width: 100%; + + #mainform { + border: 1px solid #e8e8e8; + } + + span.description { + display: block; + margin-top: 5px; + } + + input[type=text], input[type=email] { + width: 100%; + max-width: 400px; + } + + .sm-nav-tab-wrapper { + background: white; + padding: 0; + border-bottom: 1px solid #e8e8e8; + + .nav-tab { + float: none; + border: none; + margin: 0; + padding: 20px 20px; + display: inline-block; + background: none; + font-weight: normal; + color: #666; + font-size: 13px; + + &:hover, &:active, &:focus { + border-bottom: 2px solid #ccc; + outline: none; + box-shadow: none; + } + } + + .nav-tab-active, .nav-tab-active:focus, .nav-tab-active:focus:active, .nav-tab-active:hover { + border-bottom: 2px solid #4abcf0; + } + } + + .inside { + padding: .2rem 1rem .01rem 1rem; + background: white; + } +} + +.settings-side { + width: 30%; + max-width: 300px; + margin-left: 1rem; + + .sm-box { + h3 { + margin-left: .8rem; + } + + .description { + text-align: center; + font-size: 0.85em; + padding: 0.4rem 0 0 + } + + ol { + list-style-type: circle; + } + } +} \ No newline at end of file diff --git a/assets/images/export-sm.jpg b/assets/images/export-sm.jpg new file mode 100644 index 0000000..b32f30c Binary files /dev/null and b/assets/images/export-sm.jpg differ diff --git a/assets/images/import-sb.jpg b/assets/images/import-sb.jpg new file mode 100644 index 0000000..24f9cb1 Binary files /dev/null and b/assets/images/import-sb.jpg differ diff --git a/assets/images/import-se.jpg b/assets/images/import-se.jpg new file mode 100644 index 0000000..f825097 Binary files /dev/null and b/assets/images/import-se.jpg differ diff --git a/assets/images/import-sm.jpg b/assets/images/import-sm.jpg new file mode 100644 index 0000000..3c6441f Binary files /dev/null and b/assets/images/import-sm.jpg differ diff --git a/assets/js/admin/settings.js b/assets/js/admin/settings.js new file mode 100644 index 0000000..e69de29 diff --git a/assets/js/admin/settings/podcast.js b/assets/js/admin/settings/podcast.js new file mode 100644 index 0000000..6a9c4a8 --- /dev/null +++ b/assets/js/admin/settings/podcast.js @@ -0,0 +1,33 @@ +var frame; + +function uploadImage(event) { + if (frame) { + frame.open(); + return; + } + + frame = wp.media({ + title: 'Select or Upload Cover Image', + button: { + text: 'Use this image' + }, + library: { + type: ['image'] + }, + multiple: false + }); + + frame.on('select', function () { + var attachment = frame.state().get('selection').first().toJSON(); + + jQuery(event.target).prev().val(attachment.url); + }); + + frame.open(); +} + +for (var i = 0; i < jQuery('.upload-image').length; i++) { + var button = jQuery('.upload-image'); + + button.on('click', uploadImage) +} \ No newline at end of file diff --git a/includes/admin-functions.php b/includes/admin-functions.php index d52df3e..7e2e584 100644 --- a/includes/admin-functions.php +++ b/includes/admin-functions.php @@ -3,7 +3,6 @@ add_action( 'admin_init', 'wpfc_maybe_change_downloads_upload_dir', 999 ); add_action( 'admin_menu', 'wpfc_remove_service_type_meta_box' ); -add_action( 'load-edit.php', 'wpfc_sermon_order_attach' ); add_action( 'admin_init', 'wpfc_taxonomy_short_description_actions' ); if ( preg_match( '/3.(6|7)/', get_bloginfo( 'version' ) ) ) { @@ -13,10 +12,6 @@ } add_filter( 'wpfc_validate_file', 'wpfc_sermon_audio_validate', 10, 3 ); -add_filter( 'post_updated_messages', 'wpfc_sermon_updated_messages' ); -add_action( 'manage_wpfc_sermon_posts_custom_column', 'wpfc_sermon_columns' ); -add_filter( 'manage_edit-wpfc_sermon_columns', 'wpfc_sermon_edit_columns' ); -add_filter( 'manage_edit-wpfc_sermon_sortable_columns', 'wpfc_column_register_sortable' ); /** * Checks if we should change the dir, it will change it if we should @@ -109,192 +104,6 @@ function wpfc_remove_service_type_meta_box() { remove_meta_box( 'tagsdiv-wpfc_service_type', 'wpfc_sermon', 'side' ); } -/** - * Change various messages - * - * @param array $messages Existing messages - * - * @return array - */ -function wpfc_sermon_updated_messages( $messages ) { - global $post, $post_ID; - - $messages['wpfc_sermon'] = array( - 0 => '', // Unused. Messages start at index 1. - 1 => wp_sprintf( esc_html__( 'Sermon updated. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), - 2 => esc_html__( 'Custom field updated.', 'sermon-manager-for-wordpress' ), - 3 => esc_html__( 'Custom field deleted.', 'sermon-manager-for-wordpress' ), - 4 => esc_html__( 'Sermon updated.', 'sermon-manager-for-wordpress' ), - /* translators: %s: date and time of the revision */ - 5 => isset( $_GET['revision'] ) ? wp_sprintf( esc_html__( 'Sermon restored to revision from %s', 'sermon-manager-for-wordpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => wp_sprintf( esc_html__( 'Sermon published. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), - 7 => esc_html__( 'Sermon saved.', 'sermon-manager-for-wordpress' ), - 8 => wp_sprintf( esc_html__( 'Sermon submitted. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . '' ), - 9 => wp_sprintf( esc_html__( 'Sermon scheduled for: %1$s. %2$s', 'sermon-manager-for-wordpress' ), - '' . wp_sprintf( esc_html__( '%1$s at %2$s', 'sermon-manager-for-wordpress'), get_post_time( get_option( 'date_format' ), false, null, true ), get_post_time( get_option( 'time_format' ), false, null, true ) ) . '', - '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . '' ), - 10 => wp_sprintf( esc_html__( 'Sermon draft updated. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), - ); - - return $messages; -} - -/** - * Calls ordering function on init - */ -function wpfc_sermon_order_attach() { - add_filter( 'request', 'wpfc_sermon_order' ); -} - -/** - * Orders the sermons when order is requested - * - * @param array $vars Request parameters - * - * @return array modified request parameters - */ -function wpfc_sermon_order( $vars ) { - if ( isset( $vars['post_type'] ) && $vars['post_type'] === 'wpfc_sermon' ) { - if ( isset( $vars['orderby'] ) ) { - switch ( $vars['orderby'] ) { - case 'passage': - $vars = array_merge( $vars, array( - 'meta_key' => 'bible_passage', - 'orderby' => 'meta_value' - ) ); - break; - case 'preached': - $vars = array_merge( $vars, array( - 'meta_key' => 'sermon_date', - 'orderby' => 'meta_value_num', - 'meta_value_num' => time(), - 'meta_compare' => '<=', - ) ); - break; - } - } - } - - return $vars; -} - -/** - * Register edit.php columns - * - * @return array The columns - */ -function wpfc_sermon_edit_columns() { - $columns = array( - "cb" => "", - "title" => __( 'Sermon Title', 'sermon-manager-for-wordpress' ), - /* Translators: %s: Preacher label (sentence case; singular) */ - "preacher" => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords(\SermonManager::getOption( 'preacher_label' ) ) ?: 'Preacher' ), - "series" => __( 'Sermon Series', 'sermon-manager-for-wordpress' ), - "topics" => __( 'Topics', 'sermon-manager-for-wordpress' ), - "views" => __( 'Views', 'sermon-manager-for-wordpress' ), - "preached" => __( 'Date Preached', 'sermon-manager-for-wordpress' ), - "passage" => __( 'Bible Passage', 'sermon-manager-for-wordpress' ), - ); - - return $columns; -} - -/** - * Echo data for sermon data columns in edit.php - * - * @param string $column The column being requested - * - * @return void - */ -function wpfc_sermon_columns( $column ) { - global $post; - - if ( empty( $post->ID ) ) { - echo wp_sprintf( esc_html__( '%s Can’t find sermon ID.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Error:', 'sermon-manager-for-wordpress' ) . '' ); - - return; - } - - switch ( $column ) { - case "preacher": - $data = get_the_term_list( $post->ID, 'wpfc_preacher', '', ', ', '' ); - break; - case "series": - $data = get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ); - break; - case "topics": - $data = get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ); - - // Sometimes corrupted data gets cached, clearing the cache might help - if ( $data instanceof WP_Error ) { - if ( get_transient( 'wpfc_topics_cache_cleared' ) ) { - wp_cache_delete( $post->ID, 'wpfc_sermon_topics_relationships' ); - $data = get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ); - set_transient( 'wpfc_topics_cache_cleared', 1, 60 * 60 ); - } - } - - break; - case "views": - $data = wpfc_entry_views_get( array( 'post_id' => $post->ID ) ); - break; - case "preached": - $data = date_i18n( get_option ( 'date_format' ), sm_get_the_date( 'U', $post ) ); - break; - case "passage": - $data = get_post_meta( $post->ID, 'bible_passage', true ); - break; - default: - $data = ''; - } - - if ( $data instanceof WP_Error ) { - if ( is_rtl() ) echo $data->get_error_message() . ' ' . esc_html__( 'Error:', 'sermon-manager-for-wordpress' ) . ''; - else echo '' . esc_html__( 'Error:', 'sermon-manager-for-wordpress' ) . ' ' . $data->get_error_message(); - - return; - } - - echo $data; - - return; -} - -/** - * Register the column as sortable - * @url https://gist.github.com/scribu/906872 - */ -function wpfc_column_register_sortable() { - $columns = array( - "title" => "title", - "preached" => "preached", - "preacher" => "preacher", - "series" => "series", - "topics" => "topics", - "views" => "views", - "passage" => "passage" - ); - - return $columns; -} - -/** - * Add the number of sermons to the Right Now on the Dashboard. - * Used only on WP 3.6 and 3.7. - * - * @since 2014-01-08 - */ -function wpfc_right_now() { - $num_posts = wp_count_posts( 'wpfc_sermon' ); - $num = number_format_i18n( $num_posts->publish ); - $text = _n( 'Sermon', 'Sermons', intval( $num_posts->publish ) ); - if ( current_user_can( 'edit_posts' ) ) { - $num = "$num"; - $text = "$text"; - } - echo '' . $num . '' . $text . ''; -} - /** * Adds sermon count to "At a Glance" screen */ @@ -304,6 +113,7 @@ function wpfc_dashboard() { // format the number to current locale $num = number_format_i18n( $num_posts->publish ); // put correct singular or plural text + // translators: %s integer count of sermons $text = wp_sprintf( esc_html( _n( '%s sermon', '%s sermons', intval( $num_posts->publish ), 'sermon-manager-for-wordpress' ) ), $num ); $count = '
  • '; diff --git a/includes/admin/class-sm-admin-assets.php b/includes/admin/class-sm-admin-assets.php new file mode 100644 index 0000000..55859ff --- /dev/null +++ b/includes/admin/class-sm-admin-assets.php @@ -0,0 +1,43 @@ +id : ''; + + // Register admin styles + wp_register_style( 'sm_admin_styles', SM_URL . 'assets/css/admin.css', array(), SM_VERSION ); + + // Enqueue styles for Sermon Manager pages only + if ( in_array( $screen_id, sm_get_screen_ids() ) ) { + wp_enqueue_style( 'sm_admin_styles' ); + } + } + + /** + * Enqueue scripts. + */ + public function admin_scripts() { + $screen = get_current_screen(); + $screen_id = $screen ? $screen->id : ''; + + // Enqueue scripts for Sermon Manager pages only + if ( in_array( $screen_id, sm_get_screen_ids() ) ) { + // todo: move php notice script here, but register it first above + } + } +} + +return new SM_Admin_Assets(); diff --git a/includes/admin/class-sm-admin-import-export.php b/includes/admin/class-sm-admin-import-export.php new file mode 100644 index 0000000..4fe199d --- /dev/null +++ b/includes/admin/class-sm-admin-import-export.php @@ -0,0 +1,20 @@ + '', // Unused. Messages start at index 1. + 1 => wp_sprintf( esc_html__( 'Sermon updated. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), + 2 => esc_html__( 'Custom field updated.', 'sermon-manager-for-wordpress' ), + 3 => esc_html__( 'Custom field deleted.', 'sermon-manager-for-wordpress' ), + 4 => esc_html__( 'Sermon updated.', 'sermon-manager-for-wordpress' ), + /* translators: %s: date and time of the revision */ + 5 => isset( $_GET['revision'] ) ? wp_sprintf( esc_html__( 'Sermon restored to revision from %s', 'sermon-manager-for-wordpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => wp_sprintf( esc_html__( 'Sermon published. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), + 7 => esc_html__( 'Sermon saved.', 'sermon-manager-for-wordpress' ), + 8 => wp_sprintf( esc_html__( 'Sermon submitted. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . '' ), + 9 => wp_sprintf( esc_html__( 'Sermon scheduled for: %1$s. %2$s', 'sermon-manager-for-wordpress' ), + '' . wp_sprintf( esc_html__( '%1$s at %2$s', 'sermon-manager-for-wordpress' ), get_post_time( get_option( 'date_format' ), false, null, true ), get_post_time( get_option( 'time_format' ), false, null, true ) ) . '', + '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . '' ), + 10 => wp_sprintf( esc_html__( 'Sermon draft updated. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), + ); + + return $messages; + } + + /** + * Define custom columns for sermons. + * + * @param array $existing_columns + * + * @return array + */ + public function sermon_columns( $existing_columns ) { + if ( empty( $existing_columns ) && ! is_array( $existing_columns ) ) { + $existing_columns = array(); + } + + $columns = array(); + $columns['cb'] = ''; + $columns['title'] = __( 'Sermon Title', 'sermon-manager-for-wordpress' ); + $columns['preacher'] = ucwords( \SermonManager::getOption( 'preacher_label' ) ) ?: __( 'Preacher', 'sermon-manager-for-wordpress' ); + $columns['series'] = __( 'Sermon Series', 'sermon-manager-for-wordpress' ); + $columns['topics'] = __( 'Topics', 'sermon-manager-for-wordpress' ); + $columns['views'] = __( 'Views', 'sermon-manager-for-wordpress' ); + $columns['comments'] = $existing_columns['comments']; + $columns['preached'] = __( 'Date' ); + + unset( $existing_columns['date'] ); + + return array_merge( $columns, $existing_columns ); + } + + /** + * Output custom columns for sermons. + * + * @param string $column + */ + public function render_sermon_columns( $column ) { + global $post; + + if ( empty( $post->ID ) ) { + return; + } + + switch ( $column ) { + case "preacher": + $data = get_the_term_list( $post->ID, 'wpfc_preacher', '', ', ', '' ); + break; + case "series": + $data = get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ); + break; + case "topics": + $data = get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ); + break; + case "views": + $data = wpfc_entry_views_get( array( 'post_id' => $post->ID ) ); + break; + case "preached": + /** + * Modified from code in wp-admin/includes/class-wp-posts-list-table.php + */ + global $mode; + + $data = ''; + + if ( '0000-00-00 00:00:00' === $post->post_date ) { + $t_time = $h_time = __( 'Unpublished' ); + $time_diff = 0; + } else { + $t_time = sm_get_the_date( __( 'Y/m/d g:i:s a' ) ); + $m_time = sm_get_the_date( 'Y-m-d H:i:s' ); + $time = sm_get_the_date( 'U' ); + + $time_diff = time() - $time; + + if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { + $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); + } else { + $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + } + } + + if ( 'publish' === $post->post_status ) { + $status = __( 'Published' ); + } elseif ( 'future' === $post->post_status ) { + if ( $time_diff > 0 ) { + $status = '' . __( 'Missed schedule' ) . ''; + } else { + $status = __( 'Scheduled' ); + } + } else { + $status = __( 'Last Modified' ); + } + + if ( $status ) { + $data .= $status . '
    '; + } + + if ( 'excerpt' === $mode ) { + /** + * Filters the published time of the post. + * + * If `$mode` equals 'excerpt', the published time and date are both displayed. + * If `$mode` equals 'list' (default), the publish date is displayed, with the + * time and date together available as an abbreviation definition. + * + * @since 2.9 + * + * @param string $t_time The published time. + * @param WP_Post $post Post object. + * @param string $column_name The column name. + * @param string $mode The list display mode ('excerpt' or 'list'). + */ + $data .= apply_filters( 'wpfc_sermon_preached_column_time', $t_time, $post, 'date', $mode ); + } else { + + /** This filter is documented above */ + $data .= '' . apply_filters( 'wpfc_sermon_preached_column_time', $h_time, $post, 'date', $mode ) . ''; + } + + break; + default : + $data = ''; + break; + } + + if ( $data instanceof WP_Error ) { + $data = __( 'Error' ); + } + + echo $data; + } + + /** + * Make columns sortable + * + * @param array $columns + * + * @return array + */ + public function sermon_sortable_columns( $columns ) { + $custom = array( + 'title' => 'title', + 'preached' => 'preached', + 'views' => 'views', + ); + + return wp_parse_args( $custom, $columns ); + } + + /** + * Set list table primary column + * Support for WordPress 4.3. + * + * @param string $default + * @param string $screen_id + * + * @return string + */ + public function list_table_primary_column( $default, $screen_id ) { + if ( 'edit-wpfc_sermon' === $screen_id ) { + return 'title'; + } + + return $default; + } + + /** + * Set row actions for sermons + * + * @param array $actions + * @param WP_Post $post + * + * @return array + */ + public function row_actions( $actions, $post ) { + if ( 'wpfc_sermon' === $post->post_type ) { + return array_merge( array( 'id' => 'ID: ' . $post->ID ), $actions ); + } + + return $actions; + } + + /** + * Filters and sorting handler. + * + * @param array $vars + * + * @return array + */ + public function request_query( $vars ) { + global $typenow; + + if ( 'wpfc_sermon' === $typenow ) { + // Sorting + if ( isset( $vars['orderby'] ) ) { + switch ( $vars['orderby'] ) { + case 'preached': + $vars = array_merge( $vars, array( + 'meta_key' => 'sermon_date', + 'orderby' => 'meta_value_num', + 'meta_value_num' => time(), + 'meta_compare' => '<=', + ) ); + break; + + case 'views': + $vars = array_merge( $vars, array( + 'meta_key' => 'Views', + 'orderby' => 'meta_value_num', + ) ); + break; + } + } + } + + return $vars; + } + + /** + * Change title boxes in admin. + * + * @param string $text + * @param object $post + * + * @return string + */ + public function enter_title_here( $text, $post ) { + if ( $post->post_type === 'wpfc_sermon' ) { + $text = __( 'Sermon title', 'sermon-manager-for-wordpress' ); + } + + return $text; + } + + /** + * Filter the sermons in admin based on options + * + * @param mixed $query + */ + public function sermon_filters_query( $query ) { + global $typenow; + + if ( 'wpfc_sermon' == $typenow ) { + if ( isset( $query->query_vars['wpfc_service_type'] ) ) { + $query->query_vars['tax_query'] = array( + array( + 'taxonomy' => 'wpfc_service_type', + 'field' => 'slug', + 'terms' => $query->query_vars['wpfc_service_type'] + ) + ); + } + } + } + + /** + * Filters for post types. + */ + public function restrict_manage_posts() { + global $typenow; + + if ( 'wpfc_sermon' === $typenow ) { + $this->sermon_filters(); + } + } + + /** + * Show a service type filter box. + */ + public function sermon_filters() { + global $wp_query; + + // Type filtering + $terms = get_terms( 'wpfc_service_type' ); + $output = ''; + + echo apply_filters( 'sm_sermon_filters', $output ); + } +} + +new SM_Admin_Post_Types(); \ No newline at end of file diff --git a/includes/admin/class-sm-admin-settings.php b/includes/admin/class-sm-admin-settings.php new file mode 100644 index 0000000..06864fb --- /dev/null +++ b/includes/admin/class-sm-admin-settings.php @@ -0,0 +1,805 @@ + 0 ) { + foreach ( self::$errors as $error ) { + echo '

    ' . esc_html( $error ) . '

    '; + } + } elseif ( sizeof( self::$messages ) > 0 ) { + foreach ( self::$messages as $message ) { + echo '

    ' . esc_html( $message ) . '

    '; + } + } + } + + /** + * Settings page. + * + * Handles the display of the main Sermon Manager settings page in admin. + */ + public static function output() { + global $current_section, $current_tab; + + do_action( 'sm_settings_start' ); + + wp_enqueue_script( 'sm_settings', SM_URL . 'assets/js/admin/settings.js', array( + 'jquery', + 'jquery-ui-datepicker', + 'jquery-ui-sortable' + ), SM_VERSION, true ); + + wp_register_script( 'sm_settings_podcast', SM_URL . 'assets/js/admin/settings/podcast.js', 'sm_settings', SM_VERSION, true ); + + wp_localize_script( 'sm_settings', 'sm_settings_params', array( + 'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'sermon-manager-for-wordpress' ), + ) ); + + // Include settings pages + self::get_settings_pages(); + + // Get current tab/section + $current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_title( $_GET['tab'] ); + $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] ); + + // Save settings if data has been posted + if ( ! empty( $_POST ) ) { + self::save(); + } + + // Add any posted messages + if ( ! empty( $_GET['sm_error'] ) ) { + self::add_error( stripslashes( $_GET['sm_error'] ) ); + } + + if ( ! empty( $_GET['sm_message'] ) ) { + self::add_message( stripslashes( $_GET['sm_message'] ) ); + } + + if ( $current_tab === 'podcast' ) { + wp_enqueue_script( 'sm_settings_podcast' ); // todo: i18n the script & make it more dynamic + wp_enqueue_media(); + } + + // Get tabs for the settings page + /** @noinspection PhpUnusedLocalVariableInspection */ + $tabs = apply_filters( 'sm_settings_tabs_array', array() ); + + include 'views/html-admin-settings.php'; + } + + /** + * Include the settings page classes. + */ + public static function get_settings_pages() { + if ( empty( self::$settings ) ) { + $settings = array(); + + include_once 'settings/class-sm-settings-page.php'; + + $settings[] = include 'settings/class-sm-settings-general.php'; + $settings[] = include 'settings/class-sm-settings-verse.php'; + $settings[] = include 'settings/class-sm-settings-podcast.php'; + + self::$settings = apply_filters( 'sm_get_settings_pages', $settings ); + } + + return self::$settings; + } + + /** + * Save the settings. + */ + public static function save() { + global $current_tab; + + if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'sm-settings' ) ) { + die( __( 'Action failed. Please refresh the page and retry.', 'sermon-manager-for-wordpress' ) ); + } + + // Trigger actions + do_action( 'sm_settings_save_' . $current_tab ); + do_action( 'sn_update_options_' . $current_tab ); + do_action( 'sm_update_options' ); + + self::add_message( __( 'Your settings have been saved.', 'sermon-manager-for-wordpress' ) ); + + // Clear any unwanted data and flush rules + wp_schedule_single_event( time(), 'sm_flush_rewrite_rules' ); + + do_action( 'sm_settings_saved' ); + } + + /** + * Add a message. + * + * @param string $text + */ + public static function add_message( $text ) { + self::$messages[] = $text; + } + + /** + * Add an error. + * + * @param string $text + */ + public static function add_error( $text ) { + self::$errors[] = $text; + } + + /** + * Output admin fields. + * + * Loops though the Sermon Manager options array and outputs each field. + * + * @param array[] $options Opens array to output + */ + public static function output_fields( $options ) { + foreach ( $options as $value ) { + if ( ! isset( $value['type'] ) ) { + continue; + } + if ( ! isset( $value['id'] ) ) { + $value['id'] = ''; + } + if ( ! isset( $value['title'] ) ) { + $value['title'] = isset( $value['name'] ) ? $value['name'] : ''; + } + if ( ! isset( $value['class'] ) ) { + $value['class'] = ''; + } + if ( ! isset( $value['css'] ) ) { + $value['css'] = ''; + } + if ( ! isset( $value['default'] ) ) { + $value['default'] = ''; + } + if ( ! isset( $value['desc'] ) ) { + $value['desc'] = ''; + } + if ( ! isset( $value['desc_tip'] ) ) { + $value['desc_tip'] = false; + } + if ( ! isset( $value['placeholder'] ) ) { + $value['placeholder'] = ''; + } + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) { + foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; + } + } + + // Description handling + // Reset variables + $tooltip_html = $description = ''; + // Get descriptions + $field_description = self::get_field_description( $value ); + extract( $field_description ); + + // Switch based on type + switch ( $value['type'] ) { + // Section Titles + case 'title': + if ( ! empty( $value['title'] ) ) { + echo '

    ' . esc_html( $value['title'] ) . '

    '; + } + if ( ! empty( $value['desc'] ) ) { + echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); + } + echo '' . "\n\n"; + if ( ! empty( $value['id'] ) ) { + do_action( 'sm_settings_' . sanitize_title( $value['id'] ) ); + } + break; + + // Section Ends + case 'sectionend': + if ( ! empty( $value['id'] ) ) { + do_action( 'sm_settings_' . sanitize_title( $value['id'] ) . '_end' ); + } + echo '
    '; + if ( ! empty( $value['id'] ) ) { + do_action( 'sm_settings_' . sanitize_title( $value['id'] ) . '_after' ); + } + break; + + // Standard text inputs and subtypes like 'number' + case 'text': + case 'email': + case 'number': + case 'password' : + if ( substr( $value['id'], 0, 2 ) === '__' && strlen( $value['id'] ) > 2 ) { + $option_value = $value['value']; + } else { + $option_value = self::get_option( $value['id'], $value['default'] ); + } + + ?> + + + + + + + + + /> + + + + + + + + + ‎ + + + />‎ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    + + + + + + +
    + + + + + + +
    + + + " . __( 'The settings of this image size have been disabled because its values are being overwritten by a filter.', 'sermon-manager' ) . "

    "; + } + + ?> + + + + + + + id="-width" + type="text" size="3" + value=""/> × + + id="-height" + type="text" size="3" + value=""/>px + + + + + $value['id'], + 'id' => $value['id'], + 'sort_column' => 'menu_order', + 'sort_order' => 'ASC', + 'show_option_none' => ' ', + 'class' => $value['class'], + 'echo' => false, + 'selected' => absint( self::get_option( $value['id'] ) ), + ); + + if ( isset( $value['args'] ) ) { + $args = wp_parse_args( $value['args'], $args ); + } + + ?> + + + + + + + + + + + + + + + + /> + + + + + + +

    + + + + +
    + + ' . wp_kses_post( $description ) . '

    '; + } elseif ( $description && in_array( $value['type'], array( 'checkbox' ) ) ) { + $description = wp_kses_post( $description ); + } elseif ( $description ) { + $description = '' . wp_kses_post( $description ) . ''; + } + + if ( $tooltip_html && in_array( $value['type'], array( 'checkbox' ) ) ) { + $tooltip_html = '

    ' . $tooltip_html . '

    '; + } elseif ( $tooltip_html ) { + $tooltip_html = sm_help_tip( $tooltip_html ); + } + + return array( + 'description' => $description, + 'tooltip_html' => $tooltip_html, + ); + } + + /** + * Get a setting from the settings API. + * + * @param string $option_name + * @param mixed $default + * + * @return mixed + */ + public static function get_option( $option_name, $default = '' ) { + // Array value + if ( strstr( $option_name, '[' ) ) { + + parse_str( $option_name, $option_array ); + + // Option name is first key + $option_name = current( array_keys( $option_array ) ); + + // Get value + $option_values = get_option( 'sermonmanager_' . $option_name, '' ); + + $key = key( $option_array[ $option_name ] ); + + if ( isset( $option_values[ $key ] ) ) { + $option_value = $option_values[ $key ]; + } else { + $option_value = null; + } + + // Single value + } else { + $option_value = get_option( 'sermonmanager_' . $option_name, null ); + + if ( $option_value !== null ) { + switch ( $option_name ) { + case 'itunes_sub_category': + $categories = array( + '0' => __( 'Sub Category', 'sermon-manager-for-wordpress' ), + '1' => __( 'Buddhism', 'sermon-manager-for-wordpress' ), + '2' => __( 'Christianity', 'sermon-manager-for-wordpress' ), + '3' => __( 'Hinduism', 'sermon-manager-for-wordpress' ), + '4' => __( 'Islam', 'sermon-manager-for-wordpress' ), + '5' => __( 'Judaism', 'sermon-manager-for-wordpress' ), + '6' => __( 'Other', 'sermon-manager-for-wordpress' ), + '7' => __( 'Spirituality', 'sermon-manager-for-wordpress' ), + ); + + $option_value = $categories[ $option_value ]; + break; + } + } + } + + if ( is_array( $option_value ) ) { + $option_value = array_map( 'stripslashes', $option_value ); + } elseif ( ! is_null( $option_value ) ) { + $option_value = stripslashes( $option_value ); + } + + if ( $option_value === 'no' || $option_value === 'yes' ) { + $option_value = $option_value === 'yes' ? true : false; + } + + return ( null === $option_value ) ? $default : $option_value; + } + + /** + * Save admin fields. + * + * Loops though the Sermon Manager options array and outputs each field. + * + * @param array $options Options array to output + * @param array $data Optional. Data to use for saving. Defaults to $_POST. + * + * @return bool + */ + public static function save_fields( $options, $data = null ) { + if ( is_null( $data ) ) { + $data = $_POST; + } + if ( empty( $data ) ) { + return false; + } + + // Options to update will be stored here and saved later. + $update_options = array(); + + // Loop options and get values to save. + foreach ( $options as $option ) { + if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { + continue; + } + + if ( substr( $option['id'], 0, 2 ) === '__' && strlen( $option['id'] ) > 2 ) { + continue; + } + + // Get posted value. + if ( strstr( $option['id'], '[' ) ) { + parse_str( $option['id'], $option_name_array ); + $option_name = current( array_keys( $option_name_array ) ); + $setting_name = key( $option_name_array[ $option_name ] ); + $raw_value = isset( $data[ $option_name ][ $setting_name ] ) ? wp_unslash( $data[ $option_name ][ $setting_name ] ) : null; + } else { + $option_name = $option['id']; + $setting_name = ''; + $raw_value = isset( $data[ $option['id'] ] ) ? wp_unslash( $data[ $option['id'] ] ) : null; + } + + // Format the value based on option type. + switch ( $option['type'] ) { + case 'checkbox' : + $value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no'; + break; + case 'textarea' : + $value = wp_kses_post( trim( $raw_value ) ); + break; + case 'multiselect' : + case 'multi_select_countries' : + $value = array_filter( array_map( 'sm_clean', (array) $raw_value ) ); + break; + case 'image_width' : + $value = array(); + if ( isset( $raw_value['width'] ) ) { + $value['width'] = sm_clean( $raw_value['width'] ); + $value['height'] = sm_clean( $raw_value['height'] ); + $value['crop'] = isset( $raw_value['crop'] ) ? 1 : 0; + } else { + $value['width'] = $option['default']['width']; + $value['height'] = $option['default']['height']; + $value['crop'] = $option['default']['crop']; + } + break; + case 'select': + $allowed_values = empty( $option['options'] ) ? array() : array_keys( $option['options'] ); + if ( empty( $option['default'] ) && empty( $allowed_values ) ) { + $value = null; + break; + } + $default = ( empty( $option['default'] ) ? $allowed_values[0] : $option['default'] ); + $value = in_array( $raw_value, $allowed_values ) ? $raw_value : $default; + break; + default : + $value = sm_clean( $raw_value ); + break; + } + + /** + * Sanitize the value of an option. + * + * @since 2.9 + */ + $value = apply_filters( 'sm_admin_settings_sanitize_option', $value, $option, $raw_value ); + + /** + * Sanitize the value of an option by option name. + * + * @since 2.9 + */ + $value = apply_filters( "sm_admin_settings_sanitize_option_$option_name", $value, $option, $raw_value ); + + if ( is_null( $value ) ) { + continue; + } + + // Check if option is an array and handle that differently to single values. + if ( $option_name && $setting_name ) { + if ( ! isset( $update_options[ $option_name ] ) ) { + $update_options[ $option_name ] = get_option( $option_name, array() ); + } + if ( ! is_array( $update_options[ $option_name ] ) ) { + $update_options[ $option_name ] = array(); + } + $update_options[ $option_name ][ $setting_name ] = $value; + } else { + $update_options[ $option_name ] = $value; + } + } + + // Save all options in our array. + foreach ( $update_options as $name => $value ) { + update_option( 'sermonmanager_' . $name, $value ); + } + + return true; + } +} diff --git a/includes/admin/class-sm-admin.php b/includes/admin/class-sm-admin.php new file mode 100644 index 0000000..698c764 --- /dev/null +++ b/includes/admin/class-sm-admin.php @@ -0,0 +1,45 @@ +query( "SELECT id FROM {$wpdb->prefix}sb_sermons LIMIT 1 " ) !== false; + } + + /** + * Do the import + */ + public function import() { + if ( ! doing_action( 'admin_init' ) ) { + add_action( 'admin_init', array( $this, __FUNCTION__ ) ); + + return; + } + + do_action( 'sm_import_before_sb' ); + + $this->_import_books(); + $this->_import_preachers(); + $this->_import_series(); + $this->_import_service_types(); + $this->_import_sermon_tags(); + $this->_import_sermons(); + + do_action( 'sm_import_after_sb' ); + } + + /** + * Imports Bible Books + */ + private function _import_books() { + $used_books = $this->_get_used_books(); + + foreach ( $used_books as $book ) { + if ( ! $term_data = term_exists( $book->book_name, 'wpfc_bible_book' ) ) { + $term_data = wp_insert_term( $book->book_name, 'wpfc_bible_book' ); + } + + $this->_imported_books[ $book->id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Gets the names of all Bible Books that were used in Sermon Browser + * + * @return array + */ + private function _get_used_books() { + global $wpdb; + + $used_books = array(); + $books = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_books_sermons" ); + + foreach ( $books as $book ) { + foreach ( $used_books as $used_book ) { + if ( $used_book->book_name === $book->book_name ) { + continue 2; + } + } + + $used_books[] = $book; + } + + /** + * Allows to filter books that will be imported + * + * @var array $used_books list of book names that will be imported + */ + return apply_filters( 'sm_import_sb_books', $used_books ); + } + + /** + * Imports Preachers + */ + private function _import_preachers() { + global $wpdb; + + /** + * Filter preachers that will be imported + * + * @var array Raw database data + */ + $preachers = apply_filters( 'sm_import_sb_preachers', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_preachers" ) ); + + foreach ( $preachers as $preacher ) { + if ( ! $term_data = term_exists( $preacher->name, 'wpfc_preacher' ) ) { + $term_data = wp_insert_term( $preacher->name, 'wpfc_preacher', array( + 'desc' => apply_filters( 'sm_import_sb_preacher_description', $preacher->description ?: '' ) + ) ); + } + + if ( $preacher->image !== '' ) { + // Set image + $media = wp_get_upload_dir(); + $attachment_id = sm_import_and_set_post_thumbnail( $media['baseurl'] . '/sermons/images/' . $preacher->image, 0 ); + if ( is_int( $attachment_id ) ) { + $assigned_images = get_option( 'sermon_image_plugin' ); + $assigned_images[ $term_data['term_id'] ] = $attachment_id; + update_option( 'sermon_image_plugin', $assigned_images ); + } + } + + $this->_imported_preachers[ $preacher->id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Imports Series + */ + private function _import_series() { + global $wpdb; + + /** + * Filter series that will be imported + * + * @var array Raw database data + */ + $series = apply_filters( 'sm_import_sb_series', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_series" ) ); + + foreach ( $series as $item ) { + if ( trim( $item->name ) === '' ) { + continue; + } + + if ( ! $term_data = term_exists( $item->name, 'wpfc_sermon_series' ) ) { + $term_data = wp_insert_term( $item->name, 'wpfc_sermon_series' ); + } + + $this->_imported_series[ $item->id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Imports Service Types + */ + private function _import_service_types() { + global $wpdb; + + /** + * Filter service types that will be imported + * + * @var array Raw database data + */ + $services = apply_filters( 'sm_import_sb_service_types', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_services" ) ); + + foreach ( $services as $service ) { + if ( ! $term_data = term_exists( $service->name, 'wpfc_sermon_series' ) ) { + $term_data = wp_insert_term( $service->name, 'wpfc_sermon_series' ); + } + + $this->_imported_service_types[ $service->id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Sermon tags are not working in SB, so we can't know how to import them + */ + private function _import_sermon_tags() { + return null; + } + + /** + * Imports Sermons + */ + private function _import_sermons() { + global $wpdb; + + // Imported sermons + $imported = get_option( '_sm_import_sb_messages', array() ); + + // media upload directory + $media = wp_get_upload_dir(); + + /** + * Filter sermons that will be imported + * + * @var array $sermons Raw database data + */ + $sermons = apply_filters( 'sm_import_sb_messages', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_sermons" ) ); + + + foreach ( $sermons as $sermon ) { + if ( ! isset( $imported[ $sermon->id ] ) ) { + $id = wp_insert_post( apply_filters( 'sm_import_sb_message', array( + 'post_date' => $sermon->datetime, + 'post_content' => '%todo_render%', + 'post_title' => $sermon->title, + 'post_type' => 'wpfc_sermon', + 'post_status' => 'publish', + ) ) ); + + if ( $id === 0 ) { + // silently skip if error + continue; + } + + $imported[ $sermon->id ] = array( + 'new_id' => $id + ); + + /** + * we write it after each insert in case that we get fatal error - we don't want to + * import sermons twice, it would be a mess + */ + update_option( '_sm_import_sb_messages', $imported ); + } else { + $id = $imported[ $sermon->id ]['new_id']; + } + + /** + * Filter stuff that will be imported + * + * @var array $stuff Raw database data + */ + $stuff = apply_filters( 'sm_import_sb_message_stuff', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_stuff WHERE `sermon_id` = '{$sermon->id}'" ) ); + + // set files + update_post_meta( $id, 'sm_files', $stuff ); + + // set mp3 + foreach ( $stuff as $item ) { + if ( in_array( pathinfo( $item->name, PATHINFO_EXTENSION ), array( 'mp3', 'wav', 'ogg' ) ) ) { + update_post_meta( $id, 'sermon_audio', $media['baseurl'] . '/media/audio/' . rawurlencode( $item->name ) ); + break; + } + } + + // set speaker + wp_set_object_terms( $id, intval( $this->_imported_preachers[ intval( $sermon->preacher_id ) ]['new_id'] ), 'wpfc_preacher' ); + + // set service type + wp_set_object_terms( $id, intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ), 'wpfc_service_type' ); + + // set series + wp_set_object_terms( $id, intval( $this->_imported_series[ intval( $sermon->series_id ) ]['new_id'] ), 'wpfc_sermon_series' ); + + // set description + update_post_meta( $id, 'sermon_description', $sermon->description ); + + // set passage + update_post_meta( $id, 'bible_passages_start', $sermon->start ); + update_post_meta( $id, 'bible_passages_end', $sermon->end ); + } + + // update term counts + foreach ( + array( + '_imported_preachers' => 'wpfc_preacher', + '_imported_service_types' => 'wpfc_service_type', + '_imported_series' => 'wpfc_sermon_series', + '_imported_books' => 'wpfc_bible_book', + ) as $terms_array => $taxonomy + ) { + $terms = array(); + + foreach ( $this->{$terms_array} as $item ) { + $terms[] = intval( $item['new_id'] ); + } + + _update_generic_term_count( $terms, (object) array( 'name' => $taxonomy ) ); + } + } +} diff --git a/includes/admin/import/class-sm-import-se.php b/includes/admin/import/class-sm-import-se.php new file mode 100644 index 0000000..67b50a2 --- /dev/null +++ b/includes/admin/import/class-sm-import-se.php @@ -0,0 +1,397 @@ +query( "SELECT * FROM {$wpdb->prefix}se_messages LIMIT 1 " ) !== false; + } + + /** + * Do the import + */ + public function import() { + if ( ! doing_action( 'admin_init' ) ) { + add_action( 'admin_init', array( $this, __FUNCTION__ ) ); + + return; + } + + do_action( 'sm_import_before_se' ); + + $this->_import_books(); + $this->_import_speakers(); + $this->_import_series(); + $this->_import_topics(); + $this->_import_messages(); + + do_action( 'sm_import_after_se' ); + } + + /** + * Imports Bible Books + */ + private function _import_books() { + $used_books = $this->_get_used_books(); + + foreach ( $used_books as $book ) { + if ( ! $term_data = term_exists( $book->book_name, 'wpfc_bible_book' ) ) { + $term_data = wp_insert_term( $book->book_name, 'wpfc_bible_book' ); + } + + $this->_imported_books[ $book->book_id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Gets the names of all Bible Books that were used in Series Engine + * + * @return array + */ + private function _get_used_books() { + global $wpdb; + + $used_books = array(); + $books = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_books" ); + + foreach ( $books as $book ) { + if ( ! in_array( $book->book_name, $used_books ) ) { + $used_books[] = $book; + } + } + + /** + * Filter books that will be imported + * + * @var array $books list of book data that will be imported + */ + return apply_filters( 'sm_import_se_books', $used_books ); + } + + /** + * Imports Speakers + */ + private function _import_speakers() { + global $wpdb; + + /** + * Filter speakers that will be imported + * + * @var array $speakers Raw database data + */ + $speakers = apply_filters( 'sm_import_se_speakers', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_speakers" ) ); + + foreach ( $speakers as $speaker ) { + foreach ( + array( + $speaker->first_name, + $speaker->last_name, + $speaker->first_name . ' ' . $speaker->last_name + ) as $name + ) { + if ( $term_data = term_exists( $name, 'wpfc_preacher' ) ) { + break; + } + } + + if ( empty( $term_data ) ) { + $term_data = wp_insert_term( trim( $speaker->first_name . ' ' . $speaker->last_name ), 'wpfc_preacher' ); + } + + $this->_imported_speakers[ $speaker->speaker_id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Imports Series + */ + private function _import_series() { + global $wpdb; + + /** + * Filter series that will be imported + * + * @var array $series Raw database data + */ + $series = apply_filters( 'sm_import_se_series', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_series" ) ); + + foreach ( $series as $item ) { + if ( ! $term_data = term_exists( $item->s_title, 'wpfc_sermon_series' ) ) { + $term_data = wp_insert_term( $item->s_title, 'wpfc_sermon_series', array( + 'description' => apply_filters( 'sm_import_se_series_description', $item->s_description ?: '' ) + ) ); + } + + // Set image + $attachment_id = sm_import_and_set_post_thumbnail( $item->thumbnail_url, 0 ); + if ( is_int( $attachment_id ) ) { + $assigned_images = get_option( 'sermon_image_plugin' ); + $assigned_images[ $term_data['term_id'] ] = $attachment_id; + update_option( 'sermon_image_plugin', $assigned_images ); + } + + $this->_imported_series[ $item->series_id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Imports Topics + */ + private function _import_topics() { + global $wpdb; + + /** + * Filter topics that will be imported + * + * @var array $topics Raw database data + */ + $topics = apply_filters( 'sm_import_se_topics', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_topics" ) ); + + foreach ( $topics as $topic ) { + if ( ! $term_data = term_exists( $topic->name, 'wpfc_sermon_topics' ) ) { + $term_data = wp_insert_term( $topic->name, 'wpfc_sermon_topics' ); + } + + $this->_imported_topics[ $topic->topic_id ] = array( + 'new_id' => $term_data['term_id'], + ); + } + } + + /** + * Import messages + */ + private function _import_messages() { + global $wpdb; + + // Imported messages + $imported = get_option( '_sm_import_se_messages', array() ); + + /** + * Filter messages that will be imported + * + * @var array Raw database data + */ + $messages = apply_filters( 'sm_import_se_messages', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_messages" ) ); + + /** + * Filter speaker association table that will be imported + * + * @var array Raw database data + */ + $messages_speakers = apply_filters( 'sm_import_se_speaker_association', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_message_speaker_matches" ) ); + + /** + * Filter topics association table that will be imported + * + * @var array Raw database data + */ + $messages_topics = apply_filters( 'sm_import_se_topics_association', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_message_topic_matches" ) ); + + /** + * Filter books association table that will be imported + * + * @var array Raw database data + */ + $messages_books = apply_filters( 'sm_import_se_books_association', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_book_message_matches" ) ); + + /** + * Filter series association table that will be imported + * + * @var array Raw database data + */ + $messages_series = apply_filters( 'sm_import_se_series_association', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_series_message_matches" ) ); + + // start the import + foreach ( $messages as $message ) { + $the_post = get_post( $message->wp_post_id ); + + if ( ! isset( $imported[ $message->wp_post_id ] ) ) { + $id = wp_insert_post( apply_filters( 'sm_import_se_message', array( + 'post_author' => $the_post->post_author, + 'post_date' => $the_post->post_date, + 'post_date_gmt' => $the_post->post_date_gmt, + 'post_content' => '%todo_render%', + 'post_title' => $message->title, + 'post_status' => $the_post->post_status, + 'post_type' => 'wpfc_sermon', + 'post_modified' => $the_post->post_modified, + 'post_modified_gmt' => $the_post->post_modified_gmt, + ) ) ); + + if ( $id === 0 ) { + // silently skip if error + continue; + } + + $imported[ $message->wp_post_id ] = array( + 'new_id' => $id + ); + + /** + * we write it after each insert in case that we get fatal error - we don't want to + * import messages twice, it would be a mess + */ + update_option( '_sm_import_se_messages', $imported ); + } else { + $id = $imported[ $message->wp_post_id ]['new_id']; + } + + // set speakers + if ( $keys = array_keys( array_map( function ( $element ) { + return $element->message_id; + }, $messages_speakers ), $message->message_id ) ) { + $terms = array(); + foreach ( $keys as $key ) { + $terms[] = intval( $this->_imported_speakers[ intval( $messages_speakers[ $key ]->speaker_id ) ]['new_id'] ); + } + + if ( ! empty( $terms ) ) { + wp_set_object_terms( $id, $terms, 'wpfc_preacher' ); + } + } + + // set books + if ( $keys = array_keys( array_map( function ( $element ) { + return $element->message_id; + }, $messages_books ), $message->message_id ) ) { + $terms = array(); + foreach ( $keys as $key ) { + $terms[] = intval( $this->_imported_books[ intval( $messages_books[ $key ]->book_id ) ]['new_id'] ); + } + + if ( ! empty( $terms ) ) { + wp_set_object_terms( $id, $terms, 'wpfc_bible_book' ); + } + } + + // set topics + if ( $keys = array_keys( array_keys( array_map( function ( $element ) { + return $element->message_id; + }, $messages_topics ), $message->message_id ) ) ) { + $terms = array(); + foreach ( $keys as $key ) { + $terms[] = intval( $this->_imported_topics[ intval( $messages_topics[ $key ]->topic_id ) ]['new_id'] ); + } + + if ( ! empty( $terms ) ) { + wp_set_object_terms( $id, $terms, 'wpfc_sermon_topics' ); + } + } + + // set series + if ( $keys = array_keys( array_map( function ( $element ) { + return $element->message_id; + }, $messages_series ), $message->message_id ) ) { + $terms = array(); + foreach ( $keys as $key ) { + $terms[] = intval( $this->_imported_series[ intval( $messages_series[ $key ]->series_id ) ]['new_id'] ); + } + + if ( ! empty( $terms ) ) { + wp_set_object_terms( $id, $terms, 'wpfc_sermon_series' ); + } + } + + // set scripture + if ( ! empty( $message->focus_scripture ) ) { + update_post_meta( $id, 'bible_passage', $message->focus_scripture ); + } + + // set description + if ( ! empty( $message->description ) ) { + update_post_meta( $id, 'sermon_description', $message->description ); + } + + // set sermon date + if ( ! empty( $message->date ) && $message->date !== '0000-00-00' ) { + update_post_meta( $id, 'sermon_date', $message->date ); + } + + // set audio length + if ( ! empty( $message->message_length ) ) { + update_post_meta( $id, '_wpfc_sermon_duration', substr_count( $message->message_length, ':' ) === 1 ? '00:' . $message->message_length : $message->message_length ); + } + + // set audio size (bytes) + if ( ! empty( $message->audio_file_size ) ) { + update_post_meta( $id, '_wpfc_sermon_size', $message->audio_file_size ); + } + + // set audio file + if ( ! empty( $message->audio_url ) ) { + update_post_meta( $id, 'sermon_audio', $message->audio_url ); + } + + // set video url + if ( ! empty( $message->video_url ) ) { + update_post_meta( $id, 'sermon_video_link', $message->video_url ); + } + + // set video embed + if ( ! empty( $message->embed_code ) ) { + update_post_meta( $id, 'sermon_video', $message->embed_code ); + } + + // set views + if ( ! empty( $message->audio_count ) ) { + update_post_meta( $id, 'Views', $message->audio_count ); + } + + // Update main file + if ( ! empty( $message->file_url ) ) { + update_post_meta( $id, 'sermon_notes', $message->file_url ); + } + + // Set image + sm_import_and_set_post_thumbnail( $message->message_thumbnail, $id ); + } + + // update term counts + foreach ( + array( + '_imported_speakers' => 'wpfc_preacher', + '_imported_books' => 'wpfc_bible_book', + '_imported_series' => 'wpfc_sermon_series', + '_imported_topics' => 'wpfc_sermon_topics', + ) as $terms_array => $taxonomy + ) { + $terms = array(); + + foreach ( $this->{$terms_array} as $item ) { + $terms[] = intval( $item['new_id'] ); + } + + _update_generic_term_count( $terms, (object) array( 'name' => $taxonomy ) ); + } + } +} diff --git a/includes/admin/settings/class-sm-settings-general.php b/includes/admin/settings/class-sm-settings-general.php new file mode 100644 index 0000000..a321000 --- /dev/null +++ b/includes/admin/settings/class-sm-settings-general.php @@ -0,0 +1,105 @@ +id = 'general'; + $this->label = __( 'General', 'sermon-manager-for-wordpress' ); + + parent::__construct(); + } + + /** + * Get settings array. + * + * @return array + */ + public function get_settings() { + $settings = apply_filters( 'sm_general_settings', array( + + array( + 'title' => __( 'General Settings', 'sermon-manager-for-wordpress' ), + 'type' => 'title', + 'desc' => '', + 'id' => 'general_settings' + ), + array( + 'title' => __( 'Archive Page Title', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'archive_title', + 'placeholder' => wp_sprintf( __( 'e.g. %s', 'sermon-manager-for-wordpress' ), __( 'Sermons', 'sermon-manager-for-wordpress' ) ), + ), + array( + 'title' => __( 'Archive Page Slug', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'archive_slug', + 'placeholder' => wp_sprintf( __( 'e.g. %s', 'sermon-manager-for-wordpress' ), sanitize_title( __( 'Sermons', 'sermon-manager-for-wordpress' ) ) ), + ), + array( + 'title' => __( 'Common Base Slug', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'desc' => __( 'Enable a common base slug across all taxonomies', 'sermon-manager-for-wordpress' ), + // translators: %1$s see msgid "sermons/preacher", effectively sermons/preacher + // translators: %2$s see msgid "sermons/series", effectively sermons/series + 'desc_tip' => wp_sprintf( __( 'This is for users who want to have a common base slug across all taxonomies, e.g. %1$s or %2$s.', 'sermon-manager-for-wordpress' ), '' . __( 'sermons/preacher', 'sermon-manager-for-wordpress' ) . '', '' . __( 'sermons/series', 'sermon-manager-for-wordpress' ) . '' ), + 'id' => 'common_base_slug', + ), + array( + 'title' => __( 'Enable Template Files', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + // translators: %s effectively /views + // translators: Since /views is a locale independent folder name it MUST NOT be localized + 'desc' => wp_sprintf( __( 'Enable template files found in the %s folder', 'sermon-manager-for-wordpress' ), '/views' ), + 'desc_tip' => __( 'This is for users upgrading from an older version who have issues with version 1.5+.', 'sermon-manager-for-wordpress' ), + 'id' => 'template', + ), + array( + 'title' => __( 'Disable Sermon Styles', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'desc' => __( 'Disable Sermon CSS', 'sermon-manager-for-wordpress' ), + // translators: %s effectively sermons.css + 'desc_tip' => wp_sprintf( __( 'If you do this, you should copy the styles from %s and include them in your theme CSS.', 'sermon-manager-for-wordpress' ), 'sermons.css' ), + 'id' => 'css', + ), + array( + 'title' => __( 'Display audio player or video on archive pages', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'desc' => __( 'Display audio player or video on archive pages', 'sermon-manager-for-wordpress' ), + 'id' => 'archive_player', + ), + array( + 'title' => __( 'Use old audio player', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'desc' => __( 'Use old audio player', 'sermon-manager-for-wordpress' ), + 'id' => 'use_old_player', + ), + array( + 'title' => __( 'Custom label for “Preacher”', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'desc_tip' => __( 'Note: it will also change preacher slugs.', 'sermon-manager-for-wordpress' ), + 'id' => 'preacher_label', + ), + array( + 'title' => __( 'Sermon date format', 'sermon-manager-for-wordpress' ), + 'type' => 'select', + 'desc' => __( '(used when creating a new Sermon)', 'sermon-manager-for-wordpress' ), + 'id' => 'date_format', + 'options' => array( + '0' => 'mm/dd/YY', + '1' => 'dd/mm/YY', + '2' => 'YY/mm/dd', + '3' => 'YY/dd/mm', + ) + ), + + array( 'type' => 'sectionend', 'id' => 'general_settings' ), + ) ); + + return apply_filters( 'sm_get_settings_' . $this->id, $settings ); + } +} + +return new SM_Settings_General(); diff --git a/includes/admin/settings/class-sm-settings-page.php b/includes/admin/settings/class-sm-settings-page.php new file mode 100644 index 0000000..659eb14 --- /dev/null +++ b/includes/admin/settings/class-sm-settings-page.php @@ -0,0 +1,121 @@ +id, array( $this, 'output_sections' ) ); + add_action( 'sm_settings_' . $this->id, array( $this, 'output' ) ); + add_action( 'sm_settings_save_' . $this->id, array( $this, 'save' ) ); + } + + /** + * Get settings page ID. + * + * @return string + */ + public function get_id() { + return $this->id; + } + + /** + * Get settings page label. + * + * @return string + */ + public function get_label() { + return $this->label; + } + + /** + * Add this page to settings. + * + * @param array $pages + * + * @return mixed + */ + public function add_settings_page( $pages ) { + $pages[ $this->id ] = $this->label; + + return $pages; + } + + /** + * Output sections. + */ + public function output_sections() { + global $current_section; + + $sections = $this->get_sections(); + + if ( empty( $sections ) || 1 === sizeof( $sections ) ) { + return; + } + + echo '
    '; + } + + /** + * Get sections. + * + * @return array + */ + public function get_sections() { + return apply_filters( 'sm_get_sections_' . $this->id, array() ); + } + + /** + * Output the settings. + */ + public function output() { + $settings = $this->get_settings(); + + SM_Admin_Settings::output_fields( $settings ); + } + + /** + * Get settings array. + * + * @return array + */ + public function get_settings() { + return apply_filters( 'sm_get_settings_' . $this->id, array() ); + } + + /** + * Save settings. + */ + public function save() { + global $current_section; + + $settings = $this->get_settings(); + SM_Admin_Settings::save_fields( $settings ); + + if ( $current_section ) { + do_action( 'sm_update_options_' . $this->id . '_' . $current_section ); + } + } +} \ No newline at end of file diff --git a/includes/admin/settings/class-sm-settings-podcast.php b/includes/admin/settings/class-sm-settings-podcast.php new file mode 100644 index 0000000..d61dcd3 --- /dev/null +++ b/includes/admin/settings/class-sm-settings-podcast.php @@ -0,0 +1,185 @@ +id = 'podcast'; + $this->label = __( 'Podcast', 'sermon-manager-for-wordpress' ); + add_action( 'sm_settings_podcast_settings_after', array( $this, 'after' ) ); + + parent::__construct(); + } + + /** + * Get settings array. + * + * @return array + */ + public function get_settings() { + $settings = apply_filters( 'sm_podcast_settings', array( + array( + 'title' => __( 'Podcast Settings', 'sermon-manager-for-wordpress' ), + 'type' => 'title', + 'desc' => '', + 'id' => 'podcast_settings', + ), + array( + 'title' => __( 'Title' ), + 'type' => 'text', + 'id' => 'title', + 'placeholder' => get_bloginfo( 'name' ), + ), + array( + 'title' => __( 'Description', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'description', + 'placeholder' => get_bloginfo( 'description' ), + ), + array( + 'title' => __( 'Website Link', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'website_link', + 'placeholder' => home_url(), + ), + array( + 'title' => __( 'Language', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'language', + 'placeholder' => get_bloginfo( 'language' ), + ), + array( + 'title' => __( 'Copyright', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'copyright', + 'placeholder' => wp_sprintf( __( 'Copyright © %s', 'sermon-manager-for-wordpress' ), get_bloginfo( 'name' ) ), + 'desc' => wp_sprintf( esc_html__( 'Tip: Use %s to generate a copyright symbol.', 'sermon-manager-for-wordpress' ), '' . htmlspecialchars( '©' ) . '' ), + ), + array( + 'title' => __( 'Webmaster Name', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'webmaster_name', + 'placeholder' => __( 'e.g. Your Name', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Webmaster Email', 'sermon-manager-for-wordpress' ), + 'type' => 'email', + 'id' => 'webmaster_email', + 'placeholder' => __( 'e.g. Your Email', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Author', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'itunes_author', + 'placeholder' => __( 'e.g. Primary Speaker or Church Name', 'sermon-manager-for-wordpress' ), + 'desc' => __( 'This will display at the “Artist” in the iTunes Store.', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Subtitle', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'itunes_subtitle', + 'placeholder' => wp_sprintf( __( 'e.g. Preaching and teaching audio from %s', 'sermon-manager-for-wordpress' ), get_bloginfo( 'name' ) ), + 'desc' => __( 'Your subtitle should briefly tell the listener what they can expect to hear.', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Summary', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'itunes_summary', + 'placeholder' => __( + wp_sprintf( 'e.g. Weekly teaching audio brought to you by %s in City, State.', 'sermon-manager-for-wordpress' ), + get_bloginfo( 'name' ) ), + 'desc' => __( 'Keep your Podcast Summary short, sweet and informative. Be sure to include a brief statement about your mission and in what region your audio content originates.', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Owner Name', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'itunes_owner_name', + 'placeholder' => get_bloginfo( 'name' ), + 'desc' => __( 'This should typically be the name of your Church.', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Owner Email', 'sermon-manager-for-wordpress' ), + 'type' => 'text', + 'id' => 'itunes_owner_email', + 'placeholder' => __( 'e.g. Your Email', 'sermon-manager-for-wordpress' ), + 'desc' => __( 'Use an email address that you don’t mind being made public. If someone wants to contact you regarding your Podcast this is the address they will use.', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Cover Image', 'sermon-manager-for-wordpress' ), + 'type' => 'image', + 'id' => 'itunes_cover_image', + 'desc' => __( 'This JPG will serve as the Podcast artwork in the iTunes Store. The image must be between 1,400px by 1,400px and 3,000px by 3,000px or else iTunes will not accept your feed.', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Sub Category', 'sermon-manager-for-wordpress' ), + 'type' => 'select', + 'id' => 'itunes_sub_category', + 'options' => array( + '0' => __( 'Sub Category', 'sermon-manager-for-wordpress' ), + '1' => __( 'Buddhism', 'sermon-manager-for-wordpress' ), + '2' => __( 'Christianity', 'sermon-manager-for-wordpress' ), + '3' => __( 'Hinduism', 'sermon-manager-for-wordpress' ), + '4' => __( 'Islam', 'sermon-manager-for-wordpress' ), + '5' => __( 'Judaism', 'sermon-manager-for-wordpress' ), + '6' => __( 'Other', 'sermon-manager-for-wordpress' ), + '7' => __( 'Spirituality', 'sermon-manager-for-wordpress' ), + ), + ), + array( + 'title' => __( 'PodTrac Tracking', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'id' => 'podtrac', + 'desc' => __( 'Enables PodTrac tracking.', 'sermon-manager-for-wordpress' ), + // translators: %s podtrac.com + 'desc_tip' => wp_sprintf( __( 'For more info on PodTrac or to sign up for an account, visit %s', 'sermon-manager-for-wordpress' ), 'podtrac.com' ), + ), + array( + 'title' => __( 'HTML in description', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'id' => 'enable_podcast_html_description', + 'desc' => __( 'Enables showing of HTML in iTunes description field. Uncheck if description looks messy.', 'sermon-manager-for-wordpress' ), + ), + array( + 'title' => __( 'Number of podcasts to show', 'sermon-manager-for-wordpress' ), + 'type' => 'number', + 'id' => 'podcasts_per_page', + 'placeholder' => get_option( 'posts_per_rss' ), + ), + + array( 'type' => 'sectionend', 'id' => 'podcast_settings' ), + ) ); + + return apply_filters( 'sm_get_settings_' . $this->id, $settings ); + } + + public function after() { + ?> +
    +

    + + +

    +

    + ' . esc_html__( 'Feed Validator', 'sermon-manager-for-wordpress' ) . '' ) ?> +

    +

    + ' . esc_html__( 'Submit Your Podcast', 'sermon-manager-for-wordpress' ) . '' ) ?> +

    +

    + ' . esc_html__( 'FeedBurner', 'sermon-manager-for-wordpress' ) . '' ) ?> +

    +

    + ' . esc_html__( 'iTunes FAQ for Podcast Makers', 'sermon-manager-for-wordpress' ) . '' ) ?> +

    +
    + id = 'verse'; + $this->label = __( 'Verse', 'sermon-manager-for-wordpress' ); + + parent::__construct(); + } + + /** + * Get settings array. + * + * @return array + */ + public function get_settings() { + $settings = apply_filters( 'sm_verse_settings', array( + array( + 'title' => __( 'Verse Settings', 'sermon-manager-for-wordpress' ), + 'type' => 'title', + 'desc' => '', + 'id' => 'verse_settings' + ), + array( + 'title' => __( 'Verse Popups', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'desc' => __( 'Disable Bib.ly verse popups', 'sermon-manager-for-wordpress' ), + 'id' => 'bibly', + ), + array( + 'title' => __( 'Bible Version for Verse Popups', 'sermon-manager-for-wordpress' ), + 'type' => 'select', + // translators: %s see effectively ESV + 'desc' => wp_sprintf( __( 'Warning! %s is not supported if your site uses SSL (HTTPS).', 'sermon-manager-for-wordpress' ), 'ESV' ), + 'id' => 'bibly_version', + 'options' => array( + 'KJV' => 'KJV', + 'ESV' => 'ESV', + 'NET' => 'NET', + 'LEB' => 'LEB' + ), + ), + array( + 'title' => __( 'Show key verse in widget', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'desc' => __( 'Show key verse in widget', 'sermon-manager-for-wordpress' ), + 'id' => 'widget_show_key_verse', + ), + + array( 'type' => 'sectionend', 'id' => 'verse_settings' ), + ) ); + + return apply_filters( 'sm_get_settings_' . $this->id, $settings ); + } +} + +return new SM_Settings_Verse(); diff --git a/includes/admin/sm-admin-functions.php b/includes/admin/sm-admin-functions.php new file mode 100644 index 0000000..8368ef2 --- /dev/null +++ b/includes/admin/sm-admin-functions.php @@ -0,0 +1,24 @@ +ID : $thepostid; + $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text'; + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; + + switch ( $data_type ) { + case 'url' : + $field['class'] .= ' sm_input_url'; + $field['value'] = esc_url( $field['value'] ); + break; + + default : + break; + } + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { + + foreach ( $field['custom_attributes'] as $attribute => $value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; + } + } + + echo '

    + '; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + //echo sm_help_tip( $field['description'] ); + } + + echo ' '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '

    '; +} + +/** + * Output a hidden input box. + * + * @param array $field + */ +function sm_wp_hidden_input( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['class'] = isset( $field['class'] ) ? $field['class'] : ''; + + echo ' '; +} + +/** + * Output a textarea input box. + * + * @param array $field + */ +function sm_wp_textarea_input( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['rows'] = isset( $field['rows'] ) ? $field['rows'] : 2; + $field['cols'] = isset( $field['cols'] ) ? $field['cols'] : 20; + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { + + foreach ( $field['custom_attributes'] as $attribute => $value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; + } + } + + echo '

    + '; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + //echo sm_help_tip( $field['description'] ); + } + + echo ' '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '

    '; +} + +/** + * Output a checkbox input box. + * + * @param array $field + */ +function sm_wp_checkbox( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'checkbox'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'yes'; + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { + + foreach ( $field['custom_attributes'] as $attribute => $value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; + } + } + + echo '

    + '; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + //echo sm_help_tip( $field['description'] ); + } + + echo ' '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '

    '; +} + +/** + * Output a select input box. + * + * @param array $field + */ +function sm_wp_select( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { + + foreach ( $field['custom_attributes'] as $attribute => $value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; + } + } + + echo '

    + '; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + //echo sm_help_tip( $field['description'] ); + } + + echo ' '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '

    '; +} + +/** + * Output a radio input box. + * + * @param array $field + */ +function sm_wp_radio( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + + echo '
    ' . wp_kses_post( $field['label'] ) . ''; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + //echo sm_help_tip( $field['description'] ); + } + + echo ''; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '
    '; +} diff --git a/includes/admin/views/html-admin-import-export.php b/includes/admin/views/html-admin-import-export.php new file mode 100644 index 0000000..427584e --- /dev/null +++ b/includes/admin/views/html-admin-import-export.php @@ -0,0 +1,140 @@ + +
    +
    +

    +
    +
    +

    +
    +
    +
    + <?php esc_attr_e( 'Import from file', 'sermon-manager-for-wordpress' ) ?> +
    +

    + +

    +
    + +
    +

    +
    +
    +
    +
    +
    + <?php esc_attr_e( 'Export to file', 'sermon-manager-for-wordpress' ) ?> +
    +

    + +

    +
    + +
    +

    +
    +
    +
    +
    +
    +
    +

    +

    +
    +
    +

    Plugin not installed

    +
    + <?php esc_attr_e( 'Sermon Browser', 'sermon-manager-for-wordpress' ) ?> +
    +

    + +

    +
    + +
    +

    +

    + here' ); ?> +

    +
    +
    +
    +
    +

    Plugin not installed

    +
    + <?php esc_attr_e( 'Series Engine', 'sermon-manager-for-wordpress' ) ?> +
    +

    + +

    +
    + +
    +

    +

    + here' ); ?> +

    +
    +
    +
    +
    +
    +

    + +

    +
    \ No newline at end of file diff --git a/includes/admin/views/html-admin-settings.php b/includes/admin/views/html-admin-settings.php new file mode 100644 index 0000000..83a2e0a --- /dev/null +++ b/includes/admin/views/html-admin-settings.php @@ -0,0 +1,102 @@ + +
    +
    +

    Sermon Manager Settings

    +
    +
    +
    +
    + +
    +

    + +

    + + + + +

    +
    +
    +
    +
    +
    +

    +

    +
    +

    ' . esc_html__( 'Sign up', 'sermon-manager-for-wordpress' ) . '' ); ?>

    +
    + +   + + +
    +
    + +
    +
    +
    + +
    +

    + +

    +
    +
      +
    1. + Getting Started with Sermon Manager
    2. +
    3. + Sermon Manager Shortcodes
    4. +
    5. + + Troubleshooting Sermon Manager
    6. +
    +
    + ' . esc_html__( 'knowledge base', 'sermon-manager-for-wordpress' ) . '' ); ?> +
    +
    +
    + +
    +

    + +

    +
    +

    +
    + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/includes/class-sm-api.php b/includes/class-sm-api.php index c94db35..a09c38e 100644 --- a/includes/class-sm-api.php +++ b/includes/class-sm-api.php @@ -74,10 +74,10 @@ public function save_custom_data( $post_ID, $post, $update ) { */ public function fix_ordering( $args ) { if ( $args['orderby'] === 'date' ) { - $args['orderby'] = 'meta_value_num'; - $args['meta_key'] = 'sermon_date'; - $args['meta_value_num'] = time(); - $args['meta_compare'] = '<='; + $args['orderby'] = 'meta_value_num'; + $args['meta_key'] = 'sermon_date'; + $args['meta_value_num'] = time(); + $args['meta_compare'] = '<='; } elseif ( $args['orderby'] === 'wpdate' ) { $args['orderby'] = 'date'; } diff --git a/includes/class-sm-autoloader.php b/includes/class-sm-autoloader.php new file mode 100644 index 0000000..1893aed --- /dev/null +++ b/includes/class-sm-autoloader.php @@ -0,0 +1,95 @@ +include_path = untrailingslashit( plugin_dir_path( SM_PLUGIN_FILE ) ) . '/includes/'; + } + + /** + * Auto-load SM classes on demand to reduce memory consumption. + * + * @param string $class + */ + public function autoload( $class ) { + $class = strtolower( $class ); + + if ( 0 !== strpos( $class, 'sm_' ) ) { + return; + } + + $file = $this->get_file_name_from_class( $class ); + $path = ''; + + if ( strpos( $class, 'sm_shortcode_' ) === 0 ) { + $path = $this->include_path . 'shortcodes/'; + } elseif ( strpos( $class, 'sm_meta_box' ) === 0 ) { + $path = $this->include_path . 'admin/meta-boxes/'; + } elseif ( strpos( $class, 'sm_admin' ) === 0 ) { + $path = $this->include_path . 'admin/'; + } elseif ( strpos( $class, 'sm_log_handler_' ) === 0 ) { + $path = $this->include_path . 'log-handlers/'; + } elseif ( strpos( $class, 'sm_import_' ) === 0 ) { + $path = $this->include_path . 'admin/import/'; + } + + if ( empty( $path ) || ! $this->load_file( $path . $file ) ) { + $this->load_file( $this->include_path . $file ); + } + } + + /** + * Take a class name and turn it into a file name. + * + * @param string $class The class name + * + * @return string File name + * @access private + */ + private function get_file_name_from_class( $class ) { + return 'class-' . str_replace( '_', '-', $class ) . '.php'; + } + + /** + * Include a class file. + * + * @param string $path The path to include + * + * @return bool Successful or not + * @access private + */ + private function load_file( $path ) { + if ( $path && is_readable( $path ) ) { + /** @noinspection PhpIncludeInspection */ + include_once( $path ); + + return true; + } + + return false; + } +} + +new SM_Autoloader(); diff --git a/includes/class-sm-dates-wp.php b/includes/class-sm-dates-wp.php index 3bbd467..e4c68ab 100644 --- a/includes/class-sm-dates-wp.php +++ b/includes/class-sm-dates-wp.php @@ -101,7 +101,8 @@ public static function save_series_date( $post_ID, $post, $update ) { public static function update_series_date() { foreach ( get_terms( array( - 'taxonomy' => 'wpfc_sermon_series', + 'taxonomy' => 'wpfc_sermon_series', + 'hide_empty' => false, ) ) as $term ) { $term_meta = get_term_meta( $term->term_id ); @@ -116,8 +117,31 @@ public static function update_series_date() { if ( ! empty( $dates ) ) { arsort( $dates ); - update_term_meta( $term->term_id, 'sermon_date', $dates[0] ); + $date = $dates[0]; + } else { + $query = new WP_Query( array( + 'post_type' => 'wpfc_sermon', + 'posts_per_page' => 1, + 'meta_key' => 'sermon_date', + 'meta_value_num' => time(), + 'meta_compare' => '<=', + 'orderby' => 'meta_value_num', + 'tax_query' => array( + array( + 'taxonomy' => 'wpfc_sermon_series', + 'field' => 'term_id', + 'terms' => $term->term_id + ) + ) + ) ); + if ( $query->have_posts() ) { + $date = get_post_meta( $query->posts[0]->ID, 'sermon_date', true ); + } else { + $date = 0; + } } + + update_term_meta( $term->term_id, 'sermon_date', $date ); } } } diff --git a/includes/class-sm-dates.php b/includes/class-sm-dates.php index 95b8864..a4b292f 100644 --- a/includes/class-sm-dates.php +++ b/includes/class-sm-dates.php @@ -48,7 +48,7 @@ public static function get( $format = '', $post = null, $force_unix_sanitation = // If it's already an Unix timestamp, don't convert it if ( is_numeric( $date ) && $date = intval( trim( $date ) ) ) { $dt = DateTime::createFromFormat( 'U', $date ); - if ( $dt->format( 'H' ) !== '00' && $dt->format( 'i' ) !== '00' ) { + if ( $dt->format( 'H' ) !== '00' || $dt->format( 'i' ) !== '00' ) { $has_time = true; } } else { diff --git a/includes/class-sm-error-recovery.php b/includes/class-sm-error-recovery.php deleted file mode 100644 index 6e83d6c..0000000 --- a/includes/class-sm-error-recovery.php +++ /dev/null @@ -1,321 +0,0 @@ -query( $sql ); - if ( $result->num_rows === 0 ) { - $sql = "INSERT INTO {$table_prefix}options (option_name, option_value, autoload) VALUES ('_sm_recovery_do_not_catch', '0', 'yes')"; - } else { - $sql = "UPDATE {$table_prefix}options SET option_value = '0' WHERE option_name = '_sm_recovery_do_not_catch'"; - } - $mysqli->query( $sql ); - } - - $sql = "SELECT option_value FROM {$table_prefix}options WHERE option_name = '_sm_recovery_do_not_catch'"; - $result = $mysqli->query( $sql ); - if ( $result->num_rows === 0 ) { - $does_not_exist = true; - $sm_do_not_catch = false; - } else { - $result = $result->fetch_assoc(); - $sm_do_not_catch = $result['option_value'] == 1; - } - - if ( $sm_do_not_catch ) { - return; - } - - self::$_error = error_get_last(); - - if ( self::_is_fatal() ) { - // check if it's caused by SM - self::_update_db(); - - if ( ! empty( $does_not_exist ) ) { - $sql = "INSERT INTO {$table_prefix}options (option_name, option_value, autoload) VALUES ('_sm_recovery_do_not_catch', '1', 'yes')"; - } else { - $sql = "UPDATE {$table_prefix}options SET option_value = '1' WHERE option_name = '_sm_recovery_do_not_catch'"; - } - $mysqli->query( $sql ); - - if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) === false ) { - $content = file_get_contents( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); - $headers = get_headers( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); - if ( ! ( strpos( strtolower( $content ), 'fatal error' ) === false && - $content !== '' && - substr( $headers[0], 9, 3 ) != 500 ) ) { - self::reset_db(); - } - } else { - if ( strpos( self::$_error['message'], 'sermon' ) === false && - strpos( $_SERVER['REQUEST_URI'], 'sermon' ) === false ) { - self::reset_db(); - } - } - - $mysqli->query( "UPDATE {$table_prefix}options SET option_value = '0' WHERE option_name = '_sm_recovery_do_not_catch'" ); - } - } - - /** - * Checks if PHP error is fatal - * - * @access private - * - * @return bool True if it is, false otherwise - */ - private static function _is_fatal() { - return in_array( self::$_error['type'], self::$_catch_errors ); - } - - /** - * Prevents Sermon Manager from running and saves error message for displaying - * - * @access private - */ - private static function _update_db() { - global $table_prefix; - $mysqli = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ); - - // check if set - $sql = "SELECT option_id FROM {$table_prefix}options WHERE option_name = '_sm_recovery_disable'"; - $result = $mysqli->query( $sql ); - if ( $result->num_rows === 0 ) { - $sql = "INSERT INTO {$table_prefix}options (option_name, option_value, autoload) VALUES ('_sm_recovery_disable', '1', 'yes')"; - } else { - $sql = "UPDATE {$table_prefix}options SET option_value = '1' WHERE option_name = '_sm_recovery_disable'"; - } - $mysqli->query( $sql ); - - // check if set - $sql = "SELECT option_id FROM {$table_prefix}options WHERE option_name = '_sm_recovery_last_fatal_error'"; - $result = $mysqli->query( $sql ); - if ( $result->num_rows === 0 ) { - $sql = "INSERT INTO {$table_prefix}options (option_name, option_value, autoload) VALUES ('_sm_recovery_last_fatal_error', '" . $mysqli->real_escape_string( self::_get_message() ) . "', 'yes')"; - } else { - $sql = "UPDATE {$table_prefix}options SET option_value = '" . $mysqli->real_escape_string( self::_get_message() ) . "' WHERE option_name = '_sm_recovery_last_fatal_error'"; - } - $mysqli->query( $sql ); - } - - /** - * Gets PHP error message - * - * @access private - * - * @return string - */ - private static function _get_message() { - return self::$_error['message']; - } - - /** - * Allows Sermon Manager to run again, called on plugin update or by user - */ - public static function reset_db() { - global $table_prefix; - $mysqli = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ); - - // check if set - $sql = "SELECT option_id FROM {$table_prefix}options WHERE option_name = '_sm_recovery_disable'"; - $result = $mysqli->query( $sql ); - if ( $result->num_rows === 0 ) { - $sql = "INSERT INTO {$table_prefix}options (option_name, option_value, autoload) VALUES ('_sm_recovery_disable', '0', 'yes')"; - } else { - $sql = "UPDATE {$table_prefix}options SET option_value = '0' WHERE option_name = '_sm_recovery_disable'"; - } - - $mysqli->query( $sql ); - } - - /** - * Displays WordPress admin error message - */ - public static function render_admin_message() { - $plugin_data = get_plugin_data( constant( self::$_plugin_main_file ) ); - $plugin_name = $plugin_data['Name']; - $old_error = get_option( '_sm_recovery_last_fatal_error_hash' ) === md5( get_option( '_sm_recovery_last_fatal_error' ) ); - - ?> -
    -

    - - ' . esc_html( $plugin_name . '' ) ) ?> - - - -

    -

    - - - - - - - - - - - -

    - - -
    - - -
    - urlencode( str_replace( ABSPATH, '~/', get_option( '_sm_recovery_last_fatal_error' ) ) ), - 'environment_info' => 'WordPress: ' . $GLOBALS['wp_version'] . '; Server: ' . ( function_exists( 'apache_get_version' ) ? apache_get_version() : 'N/A' ) . '; PHP: ' . PHP_VERSION . '; Sermon Manager:' . SM_VERSION . ';', - 'plugin_name' => $plugin_data['Name'], - - ) ); - wp_enqueue_style( 'sm-error-recovery', SM_URL . 'assets/css/error-recovery.css', array(), SM_VERSION ); - } - - /** - * Disables send report button. - */ - public static function disable_send_report_button() { - update_option( '_sm_recovery_last_fatal_error_hash', md5( get_option( '_sm_recovery_last_fatal_error' ) ) ); - update_option( '_sm_recovery_disable_send', '1' ); - - return true; - } - - /** - * Re-allow recovery to work on update - */ - public static function upgrade_check() { - $db_version = get_option( 'sm_version' ); - if ( empty( $db_version ) || $db_version != SM_VERSION ) { - update_option( '_sm_recovery_do_not_catch', 0 ); - update_option( '_sm_recovery_disable', 0 ); - } - } - - public function init() { - $this->_hook(); - } - - /** - * Hooks into PHP error handing function and WordPress if plugin detected an error - * - * @access private - */ - private function _hook() { - register_shutdown_function( array( get_class(), 'do_catch' ) ); - add_action( 'plugins_loaded', array( get_class(), 'upgrade_check' ) ); - - if ( get_option( '_sm_recovery_disable' ) ) { - $this->_register_wp_hooks(); - define( 'sm_break', true ); - } - } - - /** - * Hooks into WP - * - * @access private - */ - private function _register_wp_hooks() { - add_action( 'admin_enqueue_scripts', array( get_class(), 'enqueue_scripts_styles' ) ); - add_action( 'admin_notices', array( get_class(), 'render_admin_message' ), 0 ); - add_action( 'wp_ajax_sm_clear_fatal_error', array( get_class(), 'reset_db' ) ); - add_action( 'wp_ajax_sm_recovery_disable_send_report', array( get_class(), 'disable_send_report_button' ) ); - } -} diff --git a/includes/class-sm-install.php b/includes/class-sm-install.php index c2c5e7c..dd0da5b 100644 --- a/includes/class-sm-install.php +++ b/includes/class-sm-install.php @@ -19,6 +19,10 @@ class SM_Install { ), '2.8.4' => array( 'sm_update_284_resave_sermons' + ), + '2.9' => array( + 'sm_update_29_fill_out_series_dates', + 'sm_update_29_convert_settings', ) ); @@ -170,7 +174,7 @@ public static function cron_schedules( $schedules ) { */ public static function plugin_action_links( $links ) { $action_links = array( - 'settings' => '' . esc_html__( 'Settings' ) . '', + 'settings' => '' . esc_html__( 'Settings' ) . '', ); return array_merge( $action_links, $links ); @@ -188,7 +192,7 @@ public static function plugin_row_meta( $links, $file ) { /** @noinspection PhpUndefinedConstantInspection */ if ( SM_BASENAME == $file ) { $row_meta = array( - 'support' => '' . esc_html__( 'Premium support', 'sermon-manager-for-wordpress' ) . '', + 'support' => '' . esc_html__( 'Premium support', 'sermon-manager-for-wordpress' ) . '', ); return array_merge( $links, $row_meta ); diff --git a/includes/class-sm-post-types.php b/includes/class-sm-post-types.php index 39f2b32..9262258 100644 --- a/includes/class-sm-post-types.php +++ b/includes/class-sm-post-types.php @@ -40,31 +40,31 @@ public static function register_taxonomies() { apply_filters( 'sm_taxonomy_objects_wpfc_preacher', array( 'wpfc_sermon' ) ), apply_filters( 'sm_taxonomy_args_wpfc_preacher', array( 'hierarchical' => false, - /* Translators: %s: Preachers label (sentence case; plural) */ - 'label' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ), + /* translators: %s Preachers label (sentence case; plural) */ + 'label' => wp_sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ), 'labels' => array( - /* Translators: %s: Preachers label (sentence case; plural) */ - 'name' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ), - /* Translators: %s: Preacher label (sentence case; singular) */ - 'singular_name' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) ), - /* Translators: %s: Preachers label (sentence case; plural) */ - 'menu_name' => sprintf( _x( '%s', 'Admin menu name', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ), - /* Translators: %s: Preachers label (lowercase; plural) */ - 'search_items' => sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), $preacher_label . 's' ), - /* Translators: %s: Preachers label (lowercase; plural) */ - 'all_items' => sprintf( __( 'All %s', 'sermon-manager-for-wordpress' ), $preacher_label . 's' ), + /* translators: %s Preachers label (sentence case; plural) */ + 'name' => wp_sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ), + /* translators: %s Preacher label (sentence case; singular) */ + 'singular_name' => wp_sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) ), + /* translators: %s Preachers label (sentence case; plural) */ + 'menu_name' => wp_sprintf( _x( '%s', 'menu', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ), + /* translators: %s Preachers label (lowercase; plural) */ + 'search_items' => wp_sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), $preacher_label . 's' ), + /* translators: %s Preachers label (lowercase; plural) */ + 'all_items' => wp_sprintf( __( 'All %s', 'sermon-manager-for-wordpress' ), $preacher_label . 's' ), 'parent_item' => null, // it's not hierarchical 'parent_item_colon' => null, // it's not hierarchical - /* Translators: %s: Preacher label (lowercase; singular) */ - 'edit_item' => sprintf( __( 'Edit %s', 'sermon-manager-for-wordpress' ), $preacher_label ), - /* Translators: %s: Preacher label (lowercase; singular) */ - 'update_item' => sprintf( __( 'Update %s', 'sermon-manager-for-wordpress' ), $preacher_label ), - /* Translators: %s: Preacher label (lowercase; singular) */ - 'add_new_item' => sprintf( __( 'Add new %s', 'sermon-manager-for-wordpress' ), $preacher_label ), - /* Translators: %s: Preacher label (lowercase; singular) */ - 'new_item_name' => sprintf( __( 'New %s name', 'sermon-manager-for-wordpress' ), $preacher_label ), - /* Translators: %s: Preacher label (lowercase; singular) */ - 'not_found' => sprintf( __( 'No %s found', 'sermon-manager-for-wordpress' ), $preacher_label ), + /* translators: %s Preacher label (lowercase; singular) */ + 'edit_item' => wp_sprintf( __( 'Edit %s', 'sermon-manager-for-wordpress' ), $preacher_label ), + /* translators: %s Preacher label (lowercase; singular) */ + 'update_item' => wp_sprintf( __( 'Update %s', 'sermon-manager-for-wordpress' ), $preacher_label ), + /* translators: %s Preacher label (lowercase; singular) */ + 'add_new_item' => wp_sprintf( __( 'Add new %s', 'sermon-manager-for-wordpress' ), $preacher_label ), + /* translators: %s Preacher label (lowercase; singular) */ + 'new_item_name' => wp_sprintf( __( 'New %s name', 'sermon-manager-for-wordpress' ), $preacher_label ), + /* translators: %s Preacher label (lowercase; singular) */ + 'not_found' => wp_sprintf( __( 'No %s found', 'sermon-manager-for-wordpress' ), $preacher_label ), ), 'show_ui' => true, 'query_var' => true, @@ -80,7 +80,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Series', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Series', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Series', 'Admin menu name', 'sermon-manager-for-wordpress' ), + 'menu_name' => _x( 'Series', 'menu', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search series', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All series', 'sermon-manager-for-wordpress' ), 'parent_item' => null, // it's not hierarchical @@ -105,7 +105,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Topics', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Topic', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Topics', 'Admin menu name', 'sermon-manager-for-wordpress' ), + 'menu_name' => _x( 'Topics', 'menu', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search topics', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All topics', 'sermon-manager-for-wordpress' ), 'parent_item' => null, @@ -130,7 +130,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Bible books', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Book', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Books', 'Admin menu name', 'sermon-manager-for-wordpress' ), + 'menu_name' => _x( 'Books', 'menu', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search books', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All books', 'sermon-manager-for-wordpress' ), 'parent_item' => null, @@ -155,7 +155,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Service Types', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Service Types', 'Admin menu name', 'sermon-manager-for-wordpress' ), + 'menu_name' => _x( 'Service Types', 'menu', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search service types', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All service types', 'sermon-manager-for-wordpress' ), 'parent_item' => null, @@ -192,7 +192,7 @@ public static function register_post_types() { 'name' => __( 'Sermons', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Sermon', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All Sermons', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Sermons', 'Admin menu name', 'sermon-manager-for-wordpress' ), + 'menu_name' => _x( 'Sermons', 'menu', 'sermon-manager-for-wordpress' ), 'add_new' => __( 'Add New', 'sermon-manager-for-wordpress' ), 'add_new_item' => __( 'Add new sermon', 'sermon-manager-for-wordpress' ), 'edit' => __( 'Edit', 'sermon-manager-for-wordpress' ), diff --git a/includes/libraries/wp-background-process.php b/includes/libraries/wp-background-process.php index f3f59a0..94040c1 100644 --- a/includes/libraries/wp-background-process.php +++ b/includes/libraries/wp-background-process.php @@ -61,20 +61,6 @@ public function __construct() { add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); } - /** - * Dispatch - * - * @access public - * @return array|WP_Error - */ - public function dispatch() { - // Schedule the cron healthcheck. - $this->schedule_event(); - - // Perform remote post. - return parent::dispatch(); - } - /** * Push to queue * @@ -103,35 +89,6 @@ public function save() { return $this; } - /** - * Update queue - * - * @param string $key Key. - * @param array $data Data. - * - * @return $this - */ - public function update( $key, $data ) { - if ( ! empty( $data ) ) { - update_site_option( $key, $data ); - } - - return $this; - } - - /** - * Delete queue - * - * @param string $key Key. - * - * @return $this - */ - public function delete( $key ) { - delete_site_option( $key ); - - return $this; - } - /** * Generate key * @@ -176,6 +133,21 @@ public function maybe_handle() { wp_die(); } + /** + * Is process running + * + * Check whether the current process is already running + * in a background process. + */ + protected function is_process_running() { + if ( get_site_transient( $this->identifier . '_process_lock' ) ) { + // Process already running. + return true; + } + + return false; + } + /** * Is queue empty * @@ -204,18 +176,49 @@ protected function is_queue_empty() { } /** - * Is process running + * Handle * - * Check whether the current process is already running - * in a background process. + * Pass each queue item to the task handler, while remaining + * within server memory and time limit constraints. */ - protected function is_process_running() { - if ( get_site_transient( $this->identifier . '_process_lock' ) ) { - // Process already running. - return true; - } + protected function handle() { + $this->lock_process(); - return false; + do { + $batch = $this->get_batch(); + + foreach ( $batch->data as $key => $value ) { + $task = $this->task( $value ); + + if ( false !== $task ) { + $batch->data[ $key ] = $task; + } else { + unset( $batch->data[ $key ] ); + update_option( 'wp_sm_updater_' . $value . '_done', 1 ); + } + + if ( $this->time_exceeded() || $this->memory_exceeded() ) { + // Batch limits reached. + break; + } + } + + // Update or delete current batch. + if ( ! empty( $batch->data ) ) { + $this->update( $batch->key, $batch->data ); + } else { + $this->delete( $batch->key ); + } + } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); + + $this->unlock_process(); + + // Start next batch or complete process. + if ( ! $this->is_queue_empty() ) { + $this->dispatch(); + } else { + $this->complete(); + } } /** @@ -234,19 +237,6 @@ protected function lock_process() { set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); } - /** - * Unlock process - * - * Unlock the process so that other instances can spawn. - * - * @return $this - */ - protected function unlock_process() { - delete_site_transient( $this->identifier . '_process_lock' ); - - return $this; - } - /** * Get batch * @@ -285,49 +275,36 @@ protected function get_batch() { } /** - * Handle + * Task * - * Pass each queue item to the task handler, while remaining - * within server memory and time limit constraints. + * Override this method to perform any actions required on each + * queue item. Return the modified item for further processing + * in the next pass through. Or, return false to remove the + * item from the queue. + * + * @param mixed $item Queue item to iterate over. + * + * @return mixed */ - protected function handle() { - $this->lock_process(); - - do { - $batch = $this->get_batch(); - - foreach ( $batch->data as $key => $value ) { - $task = $this->task( $value ); - - if ( false !== $task ) { - $batch->data[ $key ] = $task; - } else { - unset( $batch->data[ $key ] ); - update_option('wp_sm_updater_' . $value . '_done', 1 ); - } - - if ( $this->time_exceeded() || $this->memory_exceeded() ) { - // Batch limits reached. - break; - } - } - - // Update or delete current batch. - if ( ! empty( $batch->data ) ) { - $this->update( $batch->key, $batch->data ); - } else { - $this->delete( $batch->key ); - } - } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); + abstract protected function task( $item ); - $this->unlock_process(); + /** + * Time exceeded. + * + * Ensures the batch never exceeds a sensible time limit. + * A timeout limit of 30s is common on shared hosting. + * + * @return bool + */ + protected function time_exceeded() { + $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds + $return = false; - // Start next batch or complete process. - if ( ! $this->is_queue_empty() ) { - $this->dispatch(); - } else { - $this->complete(); + if ( time() >= $finish ) { + $return = true; } + + return apply_filters( $this->identifier . '_time_exceeded', $return ); } /** @@ -372,22 +349,68 @@ protected function get_memory_limit() { } /** - * Time exceeded. + * Update queue * - * Ensures the batch never exceeds a sensible time limit. - * A timeout limit of 30s is common on shared hosting. + * @param string $key Key. + * @param array $data Data. * - * @return bool + * @return $this */ - protected function time_exceeded() { - $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds - $return = false; - - if ( time() >= $finish ) { - $return = true; + public function update( $key, $data ) { + if ( ! empty( $data ) ) { + update_site_option( $key, $data ); } - return apply_filters( $this->identifier . '_time_exceeded', $return ); + return $this; + } + + /** + * Delete queue + * + * @param string $key Key. + * + * @return $this + */ + public function delete( $key ) { + delete_site_option( $key ); + + return $this; + } + + /** + * Unlock process + * + * Unlock the process so that other instances can spawn. + * + * @return $this + */ + protected function unlock_process() { + delete_site_transient( $this->identifier . '_process_lock' ); + + return $this; + } + + /** + * Dispatch + * + * @access public + * @return array|WP_Error + */ + public function dispatch() { + // Schedule the cron healthcheck. + $this->schedule_event(); + + // Perform remote post. + return parent::dispatch(); + } + + /** + * Schedule event + */ + protected function schedule_event() { + if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { + wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); + } } /** @@ -401,6 +424,17 @@ protected function complete() { $this->clear_scheduled_event(); } + /** + * Clear scheduled event + */ + protected function clear_scheduled_event() { + $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); + + if ( $timestamp ) { + wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); + } + } + /** * Schedule cron healthcheck * @@ -420,7 +454,7 @@ public function schedule_cron_healthcheck( $schedules ) { // Adds every 5 minutes to the existing schedules. $schedules[ $this->identifier . '_cron_interval' ] = array( 'interval' => MINUTE_IN_SECONDS * $interval, - 'display' => sprintf( __( 'Every %d minutes', 'sermon-manager' ), $interval ), + 'display' => wp_sprintf( __( 'Every %s minutes', 'sermon-manager-for-wordpress' ), number_format_i18n( $interval ) ), ); return $schedules; @@ -435,38 +469,19 @@ public function schedule_cron_healthcheck( $schedules ) { public function handle_cron_healthcheck() { if ( $this->is_process_running() ) { // Background process already running. - exit; + return; } if ( $this->is_queue_empty() ) { // No data to process. $this->clear_scheduled_event(); - exit; - } - $this->handle(); - - exit; - } - - /** - * Schedule event - */ - protected function schedule_event() { - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { - wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); + return; } - } - /** - * Clear scheduled event - */ - protected function clear_scheduled_event() { - $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); + $this->handle(); - if ( $timestamp ) { - wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); - } + return; } /** @@ -486,18 +501,4 @@ public function cancel_process() { } - /** - * Task - * - * Override this method to perform any actions required on each - * queue item. Return the modified item for further processing - * in the next pass through. Or, return false to remove the - * item from the queue. - * - * @param mixed $item Queue item to iterate over. - * - * @return mixed - */ - abstract protected function task( $item ); - } diff --git a/includes/options.php b/includes/options.php deleted file mode 100755 index a101275..0000000 --- a/includes/options.php +++ /dev/null @@ -1,741 +0,0 @@ -=' ) ) { - $args = array( - 'sanitize_callback' => 'wpfc_validate_options' - ); - } - - register_setting( 'wpfc_plugin_options', 'wpfc_options', $args ); - - if ( isset( $_GET['page'] ) && strpos( $_GET['page'], 'options.php' ) !== false ) { - wp_enqueue_media(); - } - } - - function wpfc_add_options_page() { - $page = add_submenu_page( 'edit.php?post_type=wpfc_sermon', __( 'Sermon Manager Settings', 'sermon-manager-for-wordpress' ), __( 'Settings', 'sermon-manager-for-wordpress' ), 'manage_options', __FILE__, array( - $this, - 'wpfc_sermon_options_render_form' - ) ); - add_action( 'admin_print_styles-' . $page, array( $this, 'wpfc_sermon_admin_styles' ) ); - } - - function wpfc_sermon_manager_settings_page_link( $link_text = '' ) { - if ( empty( $link_text ) ) { - $link_text = __( 'Manage Settings', 'sermon-manager-for-wordpress' ); - } - - $link = ''; - if ( current_user_can( 'manage_options' ) ) { - $link = '' . esc_html( $link_text ) . ''; - } - - return $link; - } - - function wpfc_sermon_admin_styles() { - wp_enqueue_script( 'media-upload' ); - wp_enqueue_script( 'jquery-ui-tabs' ); - wp_enqueue_script( 'jquery-ui-sortable' ); - wp_enqueue_script( 'jquery-ui-draggable' ); - wp_enqueue_script( 'jquery-ui-droppable' ); - } - - function wpfc_sermon_options_render_form() { - if ( ! isset( $_REQUEST['settings-updated'] ) ) { - $_REQUEST['settings-updated'] = false; - } - ?> -
    - - - -
    -

    -

    - - - - -

    -

    -
    - - -
    - -
    - -
    -

    -

    -
    -

    ' . esc_html__( 'Sign up', 'sermon-manager-for-wordpress' ) . '' ); ?>

    -
    -   - -
    -
    - -
    -
    -
    - -
    -

    - -

    -
    - -
    - ' . esc_html__( 'knowledge base', 'sermon-manager-for-wordpress' ) . '' ); ?> -
    -
    -
    - -
    -

    - -

    -
    -

    -
    - -
    -
    -
    -
    - -
    -
    -
    - - - -
    -

    - -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    ' . esc_html__( 'sermons/preacher', 'sermon-manager-for-wordpress' ) . '', '' . esc_html__( 'sermons/series', 'sermon-manager-for-wordpress' ) . '' ); ?> - -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - -
    -
    -
    - - -
    -
    -
    - -
    -

    - -

    -
    - - - - - - - - - - - -
    - -
    -
    - - - ESV', - 'NET', - 'KJV', - 'LEB', - '' . esc_html__( 'bib.ly', 'sermon-manager-for-wordpress' ) . '' ); ?> -
    - ESV' ); ?> -
    -
    -
    -
    - -
    -

    - -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    - -
    - -
    - - -

    - ' . htmlspecialchars( '©' ) . '' ); ?> -

    -
    - -
    - -
    - - -

    -
    - - -

    -
    - - -

    -
    - - -

    -
    - - -

    -
    - - - -

    -
    - - -

    -
    - - -

    -
    -
    -
    -

    podtrac.com' ); ?>

    -
    -
    -
    -

    -
    -
    -
    -

    -
    - -
    -

    -
    - -

    - -

    ' . esc_html__( 'Feed Validator', 'sermon-manager-for-wordpress' ) . '' ); ?> -

    - -

    ' . esc_html__( 'Submit Your Podcast', 'sermon-manager-for-wordpress' ) . '' ); ?> -

    - -

    ' . esc_html__( 'FeedBurner', 'sermon-manager-for-wordpress' ) . '' ); ?> -

    - -

    ' . esc_html__( 'iTunes FAQ for Podcast Makers', 'sermon-manager-for-wordpress' ) . '' ); ?> -

    -
    -
    - - -

    - -

    -
    - -
    -
    - -
    -
    - -
    - - + ID, '_wpfc_sermon_duration', true ) ?: '0:00'; $audio_file_size = get_post_meta( $post->ID, '_wpfc_sermon_size', 'true' ) ?: 0; + + // Fix for relative audio file URLs + if ( substr( $audio, 0, 1 ) === '/' ) { + $audio = home_url( $audio ); + } ?> diff --git a/includes/shortcodes.php b/includes/shortcodes.php index 988f880..61681c2 100755 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -67,6 +67,11 @@ public function displaySermonsList( $atts ) { define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); } + // unquote + foreach ( $atts as &$att ) { + $att = $this->_unquote( $att ); + } + // default options $args = array( 'display' => 'series', @@ -103,10 +108,10 @@ public function displaySermonsList( $atts ) { ); if ( $query_args['orderby'] === 'date' ) { - $query_args['orderby'] = 'meta_value_num'; - $query_args['meta_key'] = 'sermon_date'; - $query_args['meta_compare'] = '<='; - $query_args['meta_value_num'] = time(); + $query_args['orderby'] = 'meta_value_num'; + $query_args['meta_key'] = 'sermon_date'; + $query_args['meta_compare'] = '<='; + $query_args['meta_value_num'] = time(); } // get items @@ -210,6 +215,42 @@ public function displaySermonsList( $atts ) { } } + /** + * Removes all sorts of quotes from a string + * + * @see http://unicode.org/cldr/utility/confusables.jsp?a=%22&r=None + * + * @param string $string String to unquote + * + * @return mixed Unquoted string if string supplied, original variable otherwise + * + * @since 2.9 + */ + private function _unquote( $string ) { + if ( ! is_string( $string ) ) { + return $string; + } + + return str_replace( array( + "\x22", + "\x27\x27", + "\xCA\xBA", + "\xCB\x9D", + "\xCB\xAE", + "\xCB\xB6", + "\xD7\xB2", + "\xD7\xB4", + "\xE1\xB3\x93", + "\xE2\x80\x9C", + "\xE2\x80\x9D", + "\xE2\x80\x9F", + "\xE2\x80\xB3", + "\xE2\x80\xB6", + "\xE3\x80\x83", + "\xEF\xBC\x82", + ), '', $string ); + } + /** * Used to convert user friendly names to taxonomy names, i.e. "series" => "wpfc_sermon_series". * Or taxonomy names to user friendly ones. @@ -277,6 +318,11 @@ public function displayImages( $atts = array() ) { define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); } + // unquote + foreach ( $atts as &$att ) { + $att = $this->_unquote( $att ); + } + // default args $args = array( 'display' => 'series', @@ -370,6 +416,11 @@ function displayLatestSeriesImage( $atts = array() ) { define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); } + // unquote + foreach ( $atts as &$att ) { + $att = $this->_unquote( $att ); + } + // default options $args = array( 'image_class' => 'latest-series-image', @@ -574,6 +625,11 @@ public function displaySermonSorting( $atts = array() ) { define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); } + // unquote + foreach ( $atts as &$att ) { + $att = $this->_unquote( $att ); + } + // default shortcode options $args = array( 'series' => '', @@ -598,7 +654,7 @@ public function displaySermonSorting( $atts = array() ) { * @type string $atts ['sermons'] Include only these sermons. Separate with comma (,) with no spaces. IDs only. * @type string $atts ['order'] Sorting order, possible options: ASC, DESC * @type string $atts ['orderby'] Sort by: date (default), none, ID, title, name, rand, comment_count - * @type bool $atts ['hide_pagination'] true to hide the pagination (default false) + * @type bool $atts ['disable_pagination'] 1 to hide the pagination (default 0) * @type bool $atts ['image_size'] Image size. Possible values: sermon_small, sermon_medium, sermon_wide, * thumbnail, medium, large, full, or any size added with add_image_size(). (default is sermon_small) * @type string $atts ['filter_by'] Filter by series, preacher, topic, book, service_type @@ -619,31 +675,37 @@ function displaySermons( $atts = array() ) { define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); } + // unquote + foreach ( $atts as &$att ) { + $att = $this->_unquote( $att ); + } + // default options $args = array( - 'per_page' => '10', - 'sermons' => false, - 'order' => 'DESC', - 'orderby' => 'date', - 'hide_pagination' => false, - 'image_size' => 'sermon_small', - 'filter_by' => '', - 'filter_value' => '', - 'year' => '', - 'month' => '', - 'week' => '', - 'day' => '', - 'after' => '', - 'before' => '', + 'per_page' => get_option( 'posts_per_page' ) ?: 10, + 'sermons' => false, // show only sermon IDs that are set here + 'order' => 'DESC', + 'orderby' => 'date', + 'disable_pagination' => 0, + 'image_size' => 'sermon_small', + 'filter_by' => '', + 'filter_value' => '', + 'year' => '', + 'month' => '', + 'week' => '', + 'day' => '', + 'after' => '', + 'before' => '', ); // legacy convert $old_options = array( - 'posts_per_page' => 'per_page', - 'id' => 'sermons', - 'hide_nav' => 'hide_pagination', - 'taxonomy' => 'filter_by', - 'tax_term' => 'filter_value' + 'posts_per_page' => 'per_page', + 'id' => 'sermons', + 'hide_nav' => 'hide_pagination', + 'taxonomy' => 'filter_by', + 'tax_term' => 'filter_value', + 'hide_pagination' => 'disable_pagination', ); foreach ( $old_options as $old_option => $new_option ) { @@ -707,6 +769,10 @@ function displaySermons( $atts = array() ) { $args['orderby'] = 'date'; } + if ( $args['orderby'] === 'date' ){ + $args['orderby'] = 'meta_value_num'; + } + $query_args['orderby'] = $args['orderby']; // if we should show just specific sermons @@ -812,7 +878,7 @@ function displaySermons( $atts = array() ) { - +
    add_field( array( 'name' => esc_html__( 'Date Preached', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( '(optional)', 'sermon-manager-for-wordpress' ) . '
    ' . wp_sprintf( esc_html__( 'format: %s', 'sermon-manager-for-wordpress' ), $date_format ), + 'desc' => esc_html__( '(optional)', 'sermon-manager-for-wordpress' ) . '
    ' . wp_sprintf( /* translators: %s date format, effectively d/m/Y or the like */ + esc_html__( 'format: %s', 'sermon-manager-for-wordpress' ), $date_format ), 'id' => 'sermon_date', 'type' => 'text_date_timestamp', 'date_format' => $date_format, @@ -91,7 +92,8 @@ function wpfc_sermon_metaboxes() { $cmb->add_field( array( 'name' => esc_html__( 'Service Type', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Select the type of service. Modify service types in Sermons → Service Types.', 'sermon-manager-for-wordpress' ), + // translators: %s here + 'desc' => wp_sprintf( esc_html__( 'Select the type of service. Modify service types %s.', 'sermon-manager-for-wordpress' ), 'here' ), 'id' => 'wpfc_service_type', 'type' => 'select', 'show_option_none' => true, @@ -99,7 +101,8 @@ function wpfc_sermon_metaboxes() { ) ); $cmb->add_field( array( 'name' => esc_html__( 'Main Bible Passage', 'sermon-manager-for-wordpress' ), - 'desc' => wp_sprintf( esc_html__( 'Enter the Bible passage with the full book names, e.g. %s.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'John 3:16-18', 'sermon-manager-for-wordpress' ) . '' ), + 'desc' => wp_sprintf( /* translators: %s see msgid "John 3:16-18", effectively John 3:16-18 */ + esc_html__( 'Enter the Bible passage with the full book names, e.g. %s.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'John 3:16-18', 'sermon-manager-for-wordpress' ) . '' ), 'id' => 'bible_passage', 'type' => 'text', ) ); @@ -132,7 +135,8 @@ function wpfc_sermon_metaboxes() { ) ); $cmb2->add_field( array( 'name' => esc_html__( 'MP3 Duration', 'sermon-manager-for-wordpress' ), - 'desc' => wp_sprintf( esc_html__( 'Length in %s format (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'hh:mm:ss', 'sermon-manager-for-wordpress' ) . '' ), + 'desc' => wp_sprintf( /* translators: %s see msgid "hh:mm:ss", effectively hh:mm:ss */ + esc_html__( 'Length in %s format (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'hh:mm:ss', 'sermon-manager-for-wordpress' ) . '' ), 'id' => '_wpfc_sermon_duration', 'type' => 'text', ) ); @@ -155,7 +159,8 @@ function wpfc_sermon_metaboxes() { 'id' => 'sermon_notes', 'type' => 'file', 'text' => array( - 'add_upload_file_text' => esc_html__( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" + 'add_upload_file_text' => esc_html__( 'Add File', 'sermon-manager-for-wordpress' ) + // Change upload button text. Default: "Add or Upload File" ), ) ); $cmb2->add_field( array( @@ -164,7 +169,8 @@ function wpfc_sermon_metaboxes() { 'id' => 'sermon_bulletin', 'type' => 'file', 'text' => array( - 'add_upload_file_text' => esc_html__( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" + 'add_upload_file_text' => esc_html__( 'Add File', 'sermon-manager-for-wordpress' ) + // Change upload button text. Default: "Add or Upload File" ), ) ); } diff --git a/includes/sm-core-functions.php b/includes/sm-core-functions.php index 3f1fd1a..628652c 100644 --- a/includes/sm-core-functions.php +++ b/includes/sm-core-functions.php @@ -5,6 +5,8 @@ * General core functions available on both the front-end and admin. */ +defined( 'ABSPATH' ) or die; + /** * Retrieve the date on which the sermon was preached * @@ -25,9 +27,9 @@ function sm_get_the_date( $d = '', $post = null ) { } if ( '' == $d ) { - $the_date = mysql2date( get_option( 'date_format' ), $post->post_date ); + $the_date = mysql2date( get_option( 'date_format' ), $post->post_date, true ); } else { - $the_date = mysql2date( $d, $post->post_date ); + $the_date = mysql2date( $d, $post->post_date, true ); } } @@ -78,23 +80,6 @@ function sm_the_date( $d = '', $before = '', $after = '' ) { echo apply_filters( 'the_date', $the_date, $d, $before, $after ); } -/** - * Clean variables using sanitize_text_field. Arrays are cleaned recursively. - * Non-scalar values are ignored. - * - * @param string|array $var - * - * @return string|array - * @since 2.7 - */ -function sm_clean( $var ) { - if ( is_array( $var ) ) { - return array_map( 'sm_clean', $var ); - } else { - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; - } -} - /** * Get permalink settings for Sermon Manager independent of the user locale. * @@ -175,3 +160,307 @@ function sm_restore_locale() { SermonManager::load_translations(); } } + +/** + * Display a Sermon Manager help tip. + * + * @param string $tip Help tip text + * @param bool $allow_html Allow sanitized HTML if true or escape + * + * @return string + * @since 2.9 + */ +function sm_help_tip( $tip, $allow_html = false ) { + if ( $allow_html ) { + $tip = sm_sanitize_tooltip( $tip ); + } else { + $tip = esc_attr( $tip ); + } + + return ''; +} + +/** + * Get an image size. + * + * Variable is filtered by sm_get_image_size_{image_size}. + * + * @param array|string $image_size + * + * @return array + * @since 2.9 + */ +function sm_get_image_size( $image_size ) { + if ( is_array( $image_size ) ) { + $width = isset( $image_size[0] ) ? $image_size[0] : 300; + $height = isset( $image_size[1] ) ? $image_size[1] : 200; + $crop = isset( $image_size[2] ) ? $image_size[2] : true; + + $size = array( + 'width' => $width, + 'height' => $height, + 'crop' => $crop, + ); + + $image_size = $width . '_' . $height; + + } elseif ( in_array( $image_size, array( 'sermon_small', 'sermon_medium', 'sermon_wide' ) ) ) { + // reset variables + $w = $h = $c = null; + + switch ( $image_size ) { + case 'sermon_small': + $w = 75; + $h = 75; + $c = true; + + break; + case 'sermon_medium': + $w = 300; + $h = 200; + $c = true; + + break; + case 'sermon_wide': + $w = 940; + $h = 350; + $c = true; + + break; + } + + $size = get_option( $image_size . '_image_size', array() ); + $size['width'] = isset( $size['width'] ) ? $size['width'] : $w; + $size['height'] = isset( $size['height'] ) ? $size['height'] : $h; + $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : $c; + + } else { + $size = array( + 'width' => 300, + 'height' => 200, + 'crop' => true, + ); + } + + return apply_filters( 'sm_get_image_size_' . $image_size, $size ); +} + +/** + * Retrieve JPEG width and height without downloading/reading entire image. + * + * @param string $img_loc Image URL + * + * @return array|bool + * @since 2.9 + * + * @see http://php.net/manual/en/function.getimagesize.php#88793 + */ +function sm_get_jpeg_dimensions( $img_loc ) { + $handle = fopen( $img_loc, "rb" ) or die( "Invalid file stream." ); + $new_block = null; + if ( ! feof( $handle ) ) { + $new_block = fread( $handle, 32 ); + $i = 0; + if ( $new_block[ $i ] == "\xFF" && $new_block[ $i + 1 ] == "\xD8" && $new_block[ $i + 2 ] == "\xFF" && $new_block[ $i + 3 ] == "\xE0" ) { + $i += 4; + if ( $new_block[ $i + 2 ] == "\x4A" && $new_block[ $i + 3 ] == "\x46" && $new_block[ $i + 4 ] == "\x49" && $new_block[ $i + 5 ] == "\x46" && $new_block[ $i + 6 ] == "\x00" ) { + // Read block size and skip ahead to begin cycling through blocks in search of SOF marker + $block_size = unpack( "H*", $new_block[ $i ] . $new_block[ $i + 1 ] ); + $block_size = hexdec( $block_size[1] ); + while ( ! feof( $handle ) ) { + $i += $block_size; + $new_block .= fread( $handle, $block_size ); + if ( $new_block[ $i ] == "\xFF" ) { + // New block detected, check for SOF marker + $sof_marker = array( + "\xC0", + "\xC1", + "\xC2", + "\xC3", + "\xC5", + "\xC6", + "\xC7", + "\xC8", + "\xC9", + "\xCA", + "\xCB", + "\xCD", + "\xCE", + "\xCF" + ); + if ( in_array( $new_block[ $i + 1 ], $sof_marker ) ) { + // SOF marker detected. Width and height information is contained in bytes 4-7 after this byte. + $size_data = $new_block[ $i + 2 ] . $new_block[ $i + 3 ] . $new_block[ $i + 4 ] . $new_block[ $i + 5 ] . $new_block[ $i + 6 ] . $new_block[ $i + 7 ] . $new_block[ $i + 8 ]; + $unpacked = unpack( "H*", $size_data ); + $unpacked = $unpacked[1]; + $height = hexdec( $unpacked[6] . $unpacked[7] . $unpacked[8] . $unpacked[9] ); + $width = hexdec( $unpacked[10] . $unpacked[11] . $unpacked[12] . $unpacked[13] ); + + return array( $width, $height ); + } else { + // Skip block marker and read block size + $i += 2; + $block_size = unpack( "H*", $new_block[ $i ] . $new_block[ $i + 1 ] ); + $block_size = hexdec( $block_size[1] ); + } + } else { + return false; + } + } + } + } + } + + return false; +} + +/** + * Import and assign thumbnail to sermon (or any other post/CPT) + * + * Accepts remote or local image URL. + * + * - If it is a local URL and it's pointing to a path under WP uploads directory, it will check for + * database attachment existence - if it exists, it will use it. + * If database attachment does not exist - it will create it without moving the image, and will use it. + * - If it is a local URL and is not under WP uploads directory, it will act like it is a remote URL. + * - If it is a remote URL, it will save it as such. + * + * (remote URLs are not supported by default in WP, but we have a piece of code that makes them usable) + * + * @param string $image_url The URL of the image to use (local or remote) + * @param int $post_id Sermon/post to attach the image to; Passing 0 won't assign the image, it will + * just import it and return the ID of the attachment + * + * @return bool|int If $post_id is set to 0 - returns attachment ID; True|false otherwise, depending on success + * @since 2.9 + */ +function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) { + global $wpdb; + + if ( empty( $image_url ) || trim( $image_url ) === '' ) { + return false; + } + + if ( ( $attachment_id = attachment_url_to_postid( $image_url ) ) && 0 !== $attachment_id ) { + // continue + } elseif ( ( $upload = wp_upload_dir() ) && strpos( $image_url, $upload['baseurl'] ) !== false ) { + global $doing_sm_upload; + + $doing_sm_upload = true; + + if ( ! function_exists( 'media_handle_sideload' ) ) { + require_once( ABSPATH . 'wp-admin' . '/includes/image.php' ); + require_once( ABSPATH . 'wp-admin' . '/includes/file.php' ); + require_once( ABSPATH . 'wp-admin' . '/includes/media.php' ); + } + + $url = str_replace( $upload['baseurl'], $upload['basedir'], $image_url ); + preg_match( '/[^\?]+\.(jpg|jpe|jpeg|gif|png)/i', $url, $matches ); + + $attachment_id = media_handle_sideload( array( + 'name' => basename( $matches[0] ), + 'tmp_name' => $url + ), 0 ); + + $doing_sm_upload = false; + } else { + $file = wp_check_filetype( $image_url ); + + preg_match( '/[^\?]+\.(jpg|jpe|jpeg|gif|png)/i', $image_url, $matches ); + + $wpdb->insert( $wpdb->prefix . 'posts', array( + 'post_author' => get_current_user_id(), + 'post_date' => current_time( 'mysql' ), + 'post_date_gmt' => get_gmt_from_date( current_time( 'mysql' ) ), + 'post_title' => pathinfo( $matches[0], PATHINFO_FILENAME ), + 'post_status' => 'inherit', + 'comment_status' => get_default_comment_status( 'attachment' ), + 'ping_status' => get_default_comment_status( 'attachment', 'pingback' ), + 'post_name' => sanitize_title( pathinfo( $matches[0], PATHINFO_FILENAME ) ), + 'post_modified' => current_time( 'mysql' ), + 'post_modified_gmt' => get_gmt_from_date( current_time( 'mysql' ) ), + 'post_parent' => 0, + 'guid' => $image_url, + 'menu_order' => 0, + 'post_type' => 'attachment', + 'post_mime_type' => $file['type'], + 'comment_count' => 0 + ), array( + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%d', + '%s', + '%d', + '%s', + '%s', + '%d', + ) ); + + $attachment_id = $wpdb->insert_id; + + update_post_meta( $attachment_id, '_wp_attached_file', $image_url ); + + $size = sm_get_jpeg_dimensions( $image_url ); + if ( is_array( $size ) ) { + update_post_meta( $attachment_id, '_wp_attachment_metadata', array( + 'width' => $size[0], + 'height' => $size[1], + ) ); + } + } + + if ( $post_id === 0 ) { + return $attachment_id; + + } + + return set_post_thumbnail( $post_id, $attachment_id ); +} + +/** + * Get real image path in upload directory before it's overwritten + * And disable image moving + * + * @since 2.9 + */ +add_filter( 'pre_move_uploaded_file', function ( $null, $file ) { + global $upload_dir_file_path, $doing_sm_upload; + + if ( $doing_sm_upload === true ) { + $uploads = wp_get_upload_dir(); + $upload_dir_file_path = str_replace( $uploads['basedir'], '', $file['tmp_name'] ); + + return false; + } + + return $null; +}, 10, 2 ); + +/** + * Update image upload URL and path to the real image path location, + * only if executed by sm_import_and_set_post_thumbnail() + * + * @since 2.9 + */ +add_filter( 'wp_handle_upload', function ( $data ) { + global $upload_dir_file_path, $doing_sm_upload; + + if ( $doing_sm_upload === true ) { + $uploads = wp_get_upload_dir(); + $data = array( + 'file' => $uploads['basedir'] . $upload_dir_file_path, + 'url' => $uploads['baseurl'] . $upload_dir_file_path, + 'type' => $data['type'] + ); + } + + return $data; +} ); diff --git a/includes/sm-formatting-functions.php b/includes/sm-formatting-functions.php new file mode 100644 index 0000000..4db5c99 --- /dev/null +++ b/includes/sm-formatting-functions.php @@ -0,0 +1,45 @@ + array(), + 'em' => array(), + 'strong' => array(), + 'small' => array(), + 'span' => array(), + 'ul' => array(), + 'li' => array(), + 'ol' => array(), + 'p' => array(), + ) ) ); +} \ No newline at end of file diff --git a/includes/sm-update-functions.php b/includes/sm-update-functions.php index 2474dc8..1ea995e 100644 --- a/includes/sm-update-functions.php +++ b/includes/sm-update-functions.php @@ -108,4 +108,22 @@ function sm_update_28_save_sermon_render_into_post_content() { */ function sm_update_284_resave_sermons() { sm_update_28_save_sermon_render_into_post_content(); -} \ No newline at end of file +} + +/** + * There was a bug in function for 2.8, so we will do it again + */ +function sm_update_29_fill_out_series_dates() { + sm_update_28_fill_out_series_dates(); +} + +/** + * Settings storage has been changed in 2.9 + */ +function sm_update_29_convert_settings() { + $original_settings = get_option( 'wpfc_options', array() ); + + foreach ( $original_settings as $key => $value ) { + update_option( 'sermonmanager_' . $key, $value ); + } +} diff --git a/includes/taxonomy-images/code-snippets.php b/includes/taxonomy-images/code-snippets.php deleted file mode 100755 index 0112e51..0000000 --- a/includes/taxonomy-images/code-snippets.php +++ /dev/null @@ -1,192 +0,0 @@ - 'detail', - ) ); -} - -add_filter( 'the_content', 'mytheme_append_the_term_images' ); -add_filter( 'the_excerpt', 'mytheme_append_the_term_images' ); - - -/* - * Queried Term Image. - * - * Return html markup representing the image associated with the - * currently queried term. In the event that no associated image - * exists, the filter should return an empty object. - * - * In the event that the Taxonomy Images plugin is not installed - * apply_filters() will return it's second parameter. - */ - - -/* Default */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN' ); -print '

    taxonomy-images-queried-term-image

    '; -print '
    ' . htmlentities( $img ) . '
    '; - - -/* Inside a yellow box */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( - 'before' => '
    ', - 'after' => '
    ', -) ); -print '

    taxonomy-images-queried-term-image - custom wrapper element.

    '; -print '
    ' . htmlentities( $img ) . '
    '; - - -/* Medium Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'medium', -) ); -print '

    taxonomy-images-queried-term-image - medium image size

    '; -print '
    ' . htmlentities( $img ) . '
    '; - - -/* Unrecognized size */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'this-is-probably-not-a-real-image-size', -) ); -print '

    taxonomy-images-queried-term-image - unknown image size

    '; -print '
    ' . htmlentities( $img ) . '
    '; - - -/* Custom attributes. */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( - 'attr' => array( - 'alt' => 'Custom alternative text', - 'class' => 'my-class-list bunnies turtles', - 'src' => 'this-is-where-the-image-lives.png', - 'title' => 'Custom Title', - ), -) ); -print '

    taxonomy-images-queried-term-image - custom attributes

    '; -print '
    ' . htmlentities( $img ) . '
    '; - - -/* - * Queried Term Image ID. - * - * Return the id of the image associated with the currently - * queried term. In the event that no associated image exists, - * the filter should return zero. - * - * In the event that the Taxonomy Images plugin is not installed - * apply_filters() will return it's second parameter. - */ -$img = apply_filters( 'taxonomy-images-queried-term-image-id', 'PLEASE INSTALL PLUGIN' ); - -print '

    taxonomy-images-queried-term-image-id

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; - - -/* - * Queried Term Image Object. - * - * Return an object representing the image associated with the - * currently queried term. In the event that no associated image - * exists, the filter should return an empty object. - * - * In the event that the Taxonomy Images plugin is not installed - * apply_filters() will return it's second parameter. - */ -$img = apply_filters( 'taxonomy-images-queried-term-image-object', 'PLEASE INSTALL PLUGIN' ); - -print '

    taxonomy-images-queried-term-image-object

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; - - -/* - * Queried Term Image URL. - * - * Return a url to the image associated with the current queried - * term. In the event that no associated image exists, the filter - * should return an empty string. - * - * In the event that the Taxonomy Images plugin is not installed - * apply_filters() will return it's second parameter. - */ - - -/* Default */ -$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN' ); -print '

    taxonomy-images-queried-term-image-url - Default

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; - - -/* Medium Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'medium' -) ); -print '

    taxonomy-images-queried-term-image-url - Medium

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; - - -/* Unregistered Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'this-is-not-real-size-probably-I-hope' -) ); -print '

    taxonomy-images-queried-term-image-url - Unregistered

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; - - -/* - * Queried Term Image Data. - * - * Return an array of data about the image associated with the current - * queried term. In the event that no associated image exists, the filter - * should return an empty string. - * - * In the event that the Taxonomy Images plugin is not installed - * apply_filters() will return it's second parameter. - */ - - -/* Default */ -$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN' ); -print '

    taxonomy-images-queried-term-image-data - Default

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; - - -/* Medium Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'medium' -) ); -print '

    taxonomy-images-queried-term-image-data - Medium

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; - - -/* Unregistered Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'this-is-not-real-size-probably-I-hope' -) ); -print '

    taxonomy-images-queried-term-image-data - Unregistered

    '; -print '
    ';
    -var_dump( $img );
    -print '
    '; diff --git a/includes/taxonomy-images/deprecated.php b/includes/taxonomy-images/deprecated.php deleted file mode 100644 index 496aae9..0000000 --- a/includes/taxonomy-images/deprecated.php +++ /dev/null @@ -1,115 +0,0 @@ - 'category', - 'size' => 'detail', - 'template' => 'list' - ); - - extract( shortcode_atts( $defaults, $atts ) ); - - /* No taxonomy defined return an html comment. */ - if ( ! taxonomy_exists( $taxonomy ) ) { - $tax = strip_tags( trim( $taxonomy ) ); - - return ''; - } - - $terms = get_terms( $taxonomy ); - $associations = taxonomy_image_plugin_get_associations( $refresh = false ); - - if ( ! is_wp_error( $terms ) ) { - foreach ( (array) $terms as $term ) { - $url = get_term_link( $term, $term->taxonomy ); - $title = apply_filters( 'the_title', $term->name ); - $title_attr = esc_attr( $term->name . ' (' . $term->count . ')' ); - $description = apply_filters( 'the_content', $term->description ); - - $img = ''; - if ( array_key_exists( $term->term_taxonomy_id, $associations ) ) { - $img = wp_get_attachment_image( $associations[ $term->term_taxonomy_id ], 'detail', false ); - } - - if ( 'grid' == $template ) { - $o .= "\n\t" . '
    '; - $o .= "\n\t\t" . '' . $img . ''; - $o .= "\n\t" . '
    '; - } else { - $o .= "\n\t\t" . '' . $img . '';; - $o .= "\n\t\t" . '

    ' . $title . '

    '; - $o .= $description; - $o .= "\n\t" . '
    '; - $o .= "\n"; - } - } - } - - return $o; -} - -add_shortcode( 'taxonomy_image_plugin', 'taxonomy_images_plugin_shortcode_deprecated' ); - - -/** - * This class has been left for backward compatibility with versions - * of this plugin 0.5 and under. Please do not use any methods or - * properties directly in your theme. - * - * @deprecated Deprecated since version 0.5 - * @access private - */ -class taxonomy_images_plugin { - - public $settings = array(); - - public function __construct() { - $this->settings = taxonomy_image_plugin_get_associations(); - add_action( 'taxonomy_image_plugin_print_image_html', array( &$this, 'print_image_html' ), 1, 3 ); - } - - public function get_thumb( $id ) { - return taxonomy_image_plugin_get_image_src( $id ); - } - - public function print_image_html( $size = 'medium', $term_tax_id = false, $title = true, $align = 'none' ) { - print $this->get_image_html( $size, $term_tax_id, $title, $align ); - } - - public function get_image_html( $size = 'medium', $term_tax_id = false, $title = true, $align = 'none' ) { - $o = ''; - if ( false === $term_tax_id ) { - global $wp_query; - $obj = $wp_query->get_queried_object(); - if ( isset( $obj->term_taxonomy_id ) ) { - $term_tax_id = $obj->term_taxonomy_id; - } else { - return false; - } - } - $term_tax_id = (int) $term_tax_id; - if ( isset( $this->settings[ $term_tax_id ] ) ) { - $attachment_id = (int) $this->settings[ $term_tax_id ]; - $alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); - $attachment = get_post( $attachment_id ); - /* Just in case an attachment was deleted, but there is still a record for it in this plugins settings. */ - if ( $attachment !== null ) { - $o = get_image_tag( $attachment_id, $alt, '', $align, $size ); - } - } - - return $o; - } - -} - -$taxonomy_images_plugin = new taxonomy_images_plugin(); diff --git a/includes/taxonomy-images/public-filters.php b/includes/taxonomy-images/public-filters.php index b03761c..46d414a 100755 --- a/includes/taxonomy-images/public-filters.php +++ b/includes/taxonomy-images/public-filters.php @@ -382,6 +382,12 @@ function sermon_images_plugin_get_queried_term_image_id( $default ) { /* Return early is we are not in a term archive. */ if ( ! isset( $obj->term_taxonomy_id ) ) { + // translators: %1$s see msgid "term_taxonomy_id", effectively term_taxonomy_id + // translators: %2$s effectively + // translators: %3$s effectively category.php + // translators: %4$s effectively tag.php + // translators: %5$s effectively taxonomy.php + // translators: %6$s see msgid "template hierarchy" trigger_error( wp_sprintf( esc_html__( '%1$s is not a property of the current queried object. This usually happens when the %2$s filter is used in an unsupported template file. This filter has been designed to work in taxonomy archives which are traditionally served by one of the following template files: %3$s, %4$s or %5$s. Learn more about %6$s.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'term_taxonomy_id', 'sermon-manager-for-wordpress' ) . '', '' . esc_html( $filter ) . '', diff --git a/includes/taxonomy-images/readme.md b/includes/taxonomy-images/readme.md deleted file mode 100755 index 76071bf..0000000 --- a/includes/taxonomy-images/readme.md +++ /dev/null @@ -1,293 +0,0 @@ -Taxonomy Images -=============== - -A WordPress plugin that enables you to associate images from your media library to categories, tags and custom taxonomies. For usage instructions please view the [screencast](http://screenr.com/zMx). - - -Displaying Your Images in Your Theme ------------------------------------- - -There are a few filters that you can use in your theme to display the image associations created by this plugin. Please read below for detailed information. - - -Display a single image representing the term archive ----------------------------------------------------- - -The following filter will display the image associated with the term asked for in the query string of the url. This filter only works in views that naturally use templates like category.php, tag.php taxonomy.php and all of their derivatives. Please read about [template hierarchy](http://codex.wordpress.org/Template_Hierarchy) for more information about these templates. The simplest use of this filter looks like: - - print apply_filters( 'taxonomy-images-queried-term-image', '' ); - -This code will generate and print an image tag. It's output can be modifed by passig an optional third parameter to apply filters. This parameter is an array and the following keys may be set: - -* __after__ (string) - Text to append to the image's HTML. - -* __attr__ (array) - Key/value pairs representing the attributes of the img tag. Available options include: alt, class, src and title. This array will be passed as the fourth parameter to WordPress core function wp_get_attachment_image() without modification. - -* __before__ (string) - Text to prepend to the image's HTML. - -* __image_size__ (string) - May be any image size registered with WordPress. If no image size is specified, 'thumbnail' will be used as a default value. In the event that an unregistered size is specified, this filter will return an empty string. - -Here's an example of what a fully customized version of this filter might look like: - - print apply_filters( 'taxonomy-images-queried-term-image', '', array( - 'after' => '
    ' - 'attr' => array( - 'alt' => 'Custom alternative text', - 'class' => 'my-class-list bunnies turtles', - 'src' => 'this-is-where-the-image-lives.png', - 'title' => 'Custom Title', - ), - 'before' => '
    ', - 'image_size' => 'medium', - ) ); - - -Similar functionality ---------------------- - -If you just need to get the database ID for the image, you may want to use: - - $image_id = apply_filters( 'taxonomy-images-queried-term-image-id', 0 ); - -If you need to get the full object of the image, you may want to use: - - $image = apply_filters( 'taxonomy-images-queried-term-image-object', '' ); - -If you need to get the url to the image, you may want to use the following: - - $image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '' ); - -You can specify the size of the image in an option third parameter: - - $image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '', array( - 'image_size' => 'medium' - ) ); - - -If you need data about the image, you may want to use: - - $image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '' ); - -You can specify the size of the image in an option third parameter: - - - $image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '', array( - 'image_size' => 'medium' - ) ); - -List term images associated with a post object ----------------------------------------------- - -When a post is being displayed you may want to display all of the images associated with all of the terms that are associated with the post (a mouthful? Yes indeed!). The `taxonomy-images-list-the-terms` filter does this. Here's what it looks like in its simplest form: - - print apply_filters( 'taxonomy-images-list-the-terms', '' ); - -This filter accepts an optional third parameter that you can use to customize its output. It is an array which recognizes the following keys: - -* __after__ (string) - Text to append to the output. Default value is a closing unordered list element. - -* __after_image__ (string) - Text to append to each image. Default value is a closing list-item element. - -* __before__ (string) - Text to prepend to the output. Default value is an open unordered list element with an class attribute of "taxonomy-images-the-terms". - -* __before_image__ (string) - Text to prepend to each image. Default value is an open list-item element. - -* __image_size__ (string) - Any registered image size. Values will vary from installation to installation. Image sizes defined in core include: "thumbnail", "medium" and "large". "Fullsize" may also be used to get the unmodified image that was uploaded. Defaults to "thumbnail". - -* __post_id__ (int) - The post to retrieve terms from. Defaults to the ID property of the global $post object. - -* __taxonomy__ (string) - Name of a registered taxonomy to return terms from. Defaults to "category". - -Here's an example of what a fully customized version of this filter might look like: - - print apply_filters( 'taxonomy-images-list-the-terms', '', array( - 'after' => '
    ', - 'after_image' => '', - 'before' => '
    ', - 'before_image' => '', - 'image_size' => 'detail', - 'post_id' => 1234, - 'taxonomy' => 'post_tag', - ) ); - -Working with all terms of a given taxonomy ------------------------------------------- - -You will want to use the 'taxonomy-images-get-terms' filter. This filter is basically a wrapper for WordPress core function [get_terms()](http://codex.wordpress.org/Function_Reference/get_terms). It will return an array of enhanced term objects: each term object will have a custom property named image_id which is an integer representing the database ID of the image associated with the term. This filter can be used to create custom lists of terms. Here's what it's default useage looks like: - - $terms = apply_filters( 'taxonomy-images-get-terms', '' ); - -Here is what php's print_r() function may return: - - Array - ( - [0] => stdClass Object - ( - [term_id] => 8 - [name] => Pirate - [slug] => pirate - [term_group] => 0 - [term_taxonomy_id] => 8 - [taxonomy] => category - [description] => Pirates live in the ocean and ride around on boats. - [parent] => 0 - [count] => 1 - [image_id] => 44 - ) -) - -As you can see, all of the goodness of get_terms() is there with an added bonus: the image_id parameter! - -This filter recognizes an optional third parameter which is an array of arguments that can be used to modify its output: - -* __cache_images__ (bool) If this value is true all assocaite images will be queried for and cached for later use in various template tags. If it is set to false, this query will be suppressed. Do not set this value to false unless you have a really good reason for doing so :) Default value is true. - -* __having_images__ (bool) If this value is true then only terms that have associated images will be returned. Setting it to false will return all terms. Default value is true. - -* __taxonomy__ (string) Name of a registered taxonomy to return terms from. Multiple taxonomies may be specified by separating each name by a comma. Defaults to "category". - -* __term_args__ (array) Arguments to pass to [get_terms()](http://codex.wordpress.org/Function_Reference/get_terms) as the second parameter. Default value is an empty array. - -Here's and example of a simple custom loop that you can make to display all term images: - - $terms = apply_filters( 'taxonomy-images-get-terms', '' ); - if ( ! empty( $terms ) ) { - print ''; - } - - -Support -------- - -If you have questions about integrating this plugin into your site, please [add a new thread to the WordPress Support Forum](http://wordpress.org/tags/taxonomy-images?forum_id=10#postform). I try to answer these, but I may not always be able to. In the event that I cannot there may be someone else who can help. - - -Bugs, Suggestions ------------------ - -Development of this plugin is hosted in a public repository on [Github](https://github.com/mfields/Taxonomy-Images). If you find a bug in this plugin or have a suggestion to make it better, please [create a new issue](https://github.com/mfields/Taxonomy-Images/issues/new) - - -Hook it up yo! --------------- - -If you have fallen in love with this plugin and would not be able to sleep without helping out in some way, please see the following list of ways that you can _hook it up!_: - -* __Rate it!__ - Use the star tool on the right-hand sidebar of the [homepage](http://wordpress.org/extend/plugins/taxonomy-images/). - -* __Let me know if it works__ - Use the _Compatibility_ widget on the [homepage](http://wordpress.org/extend/plugins/taxonomy-images/) to let everyone know that the current version works with your version of WordPress. - -* __Do you Twitter?__ Help promote by using this shortlink: [http://bit.ly/taxonomy-images](http://bit.ly/taxonomy-images) - -* __Are you a writer?__ Help promote by writing an article on your website about this plugin. - -* __Are you Super-Wicked-Awesome?__ If so, you can always [make a donation](http://wordpress.mfields.org/donate/). - - -Need More Taxonomy Plugins? ---------------------------- - -I've released a handfull of plugins dealing with taxonomies. Please see my [plugin page](http://wordpress.org/extend/plugins/profile/mfields) for more info. - - -Installation ------------- - -1. Download -1. Unzip the package and upload to your /wp-content/plugins/ directory. -1. Log into WordPress and navigate to the "Plugins" panel. -1. Activate the plugin. -1. Click the "Taxonomy Images" link under the Settings section in the admin menu. There you can select the taxonomies that you would like to add image support for. - - -Changelog ---------- - -__0.7.3__ - -* Fixed the delete image button on edit-terms.php. -* Better escaping. -* Introduced pot file and languages directory. - -__0.7.2__ - -* Return data for fulsize images in archive views. [See this thread](http://wordpress.org/support/topic/image-size-full). - -__0.7.1__ - -* Remove unused link code which is throwing an error when no taxonomies support images. - -__0.7__ - -* No longer breaks display of the [Better Plugin Compatibility Control](http://wordpress.org/extend/plugins/better-plugin-compatibility-control/) plugin. -* Created a custom filter interface for plugin and theme integration. -* Lots of inline documentation added. -* Added custom notices if plugin is used in an unsupported way. -* No notices generated by PHP or WordPress. -* Deprecated function calls removed. -* Security updates. -* All strings are now internationalized. -* Add image to term functionality mimics "Add Featured Image". -* Taxonomy modal button now available in search + upload states. -* Image interface has been added to single term edit screen. -* Users can now choose which taxonomys have image support. -* All functions are now private. -* Shortcode deprecated. -* All global variables and constants have been removed or deprecated. - -__0.6__ - -* Never released. -* Completely recoded. - -__0.5__ - -* __UPDATE:__ Direct link to upload new files from edit-tag.php has been introduced. -* __UPDATE:__ Ability to create an image/term association immediately after upload has been introduced. -* __UPDATE:__ Users can now delete image/term associations. -* __UPDATE:__ Created standalone javascript files - removed inline scripts. -* __UPDATE:__ Obsesive compulsive syntax modifications. -* __UPDATE:__ Localization for strings - still need to "fine-tooth-comb" this. -* __UPDATE:__ Removed all debug functions. - -__0.4.4__ - -* __BUGFIX:__ get_image_html() Now populates the image's alt attribute with appropriate data. Props to [jaygoldman](http://wordpress.org/support/profile/jaygoldman). - -__0.4.3__ - -* __UPDATE:__ Support for WordPress 3.0 has been added. Support for all beta versions of 3.0 has been dropped. -* __COMPAT:__ Removed use of deprecated function is_taxonomy() - props to [anointed](http://profiles.wordpress.org/users/anointed). -* __COMPAT:__ Included a definition for taxonomy_exists() function for backwards compatibility with 2.9 branch. This function is new in WordPress version 3.0. - -__0.4.2__ - -* __UPDATE:__ Changed button name from "Category" to "Taxonomy". -* __UPDATE:__ Support for 2.9 branch has been added again. - -__0.4.1__ - -* __UPDATE:__ Added support for dynamic taxonomy hooks for _tag_row() -* __BROKEN:__ Support for 2.9 branch has been temporarily removed. - -__0.4__ - -* __BUGFIX:__ get_thumb() now returns the fullsize url if there is no appropriate intermediate image. -* __UPDATE:__ Added "taxonomy_images_shortcode". - -__0.3__ - -* __COMPAT:__ Changed the firing order of every hook untilizing the 'category_rows' method to 15. This allows this plugin to be compatible with [Reveal IDs for WP Admin](http://wordpress.org/extend/plugins/reveal-ids-for-wp-admin-25/). Thanks to [Peter Kahoun](http://profiles.wordpress.org/kahi/) -* __COMPAT:__ Added Version check for PHP5. -* __UPDATE:__ `$settings` and `$locale` are now public properties. -* __UPDATE:__ Object name changed to: $taxonomy_images_plugin. -* __UPDATE:__ Added argument $term_tax_id to both print_image_html() and get_image_html(). -* __BUGFIX:__ Deleted the register_deactivation_hook() function -> sorry to all 8 who downloaded this plugin so far :) - -__0.2__ - -* Original Release - Works With: wp 2.9.1. \ No newline at end of file diff --git a/includes/taxonomy-images/readme.txt b/includes/taxonomy-images/readme.txt deleted file mode 100755 index 83cb1ce..0000000 --- a/includes/taxonomy-images/readme.txt +++ /dev/null @@ -1,283 +0,0 @@ -===Taxonomy Images=== - -Contributors: mfields -Donate link: http://wordpress.mfields.org/donate/ -Tags: taxonomy, tag, category, image, upload, media -Requires at least: 3.1 -Tested up to: 3.2-beta2-18055 -Stable tag: trunk - -Associate images from your media library to categories, tags and custom taxonomies. - -==Description== - -For usage instructions please view the [screencast](http://screenr.com/zMx). - -= Displaying Your Images in Your Theme = - -There are a few filters that you can use in your theme to display the image associations created by this plugin. Please read below for detailed information. - -= Display a single image representing the term archive = - -The following filter will display the image associated with the term asked for in the query string of the url. This filter only works in views that naturally use templates like category.php, tag.php taxonomy.php and all of their derivatives. Please read about [template hierarchy](http://codex.wordpress.org/Template_Hierarchy) for more information about these templates. The simplest use of this filter looks like: - -`print apply_filters( 'taxonomy-images-queried-term-image', '' );` - -This code will generate and print an image tag. It's output can be modifed by passig an optional third parameter to apply filters. This parameter is an array and the following keys may be set: - -* __after__ (string) - Text to append to the image's HTML. - -* __attr__ (array) - Key/value pairs representing the attributes of the img tag. Available options include: alt, class, src and title. This array will be passed as the fourth parameter to WordPress core function wp_get_attachment_image() without modification. - -* __before__ (string) - Text to prepend to the image's HTML. - -* __image_size__ (string) - May be any image size registered with WordPress. If no image size is specified, 'thumbnail' will be used as a default value. In the event that an unregistered size is specified, this filter will return an empty string. - -Here's an example of what a fully customized version of this filter might look like: - -`print apply_filters( 'taxonomy-images-queried-term-image', '', array( - 'after' => '
    ' - 'attr' => array( - 'alt' => 'Custom alternative text', - 'class' => 'my-class-list bunnies turtles', - 'src' => 'this-is-where-the-image-lives.png', - 'title' => 'Custom Title', - ), - 'before' => '
    ', - 'image_size' => 'medium', - ) ); -` - -= Similar functionality = - -If you just need to get the database ID for the image, you may want to use: - -`$image_id = apply_filters( 'taxonomy-images-queried-term-image-id', 0 );` - -If you need to get the full object of the image, you may want to use: - -`$image = apply_filters( 'taxonomy-images-queried-term-image-object', '' );` - -If you need to get the url to the image, you may want to use the following: - -`$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '' );` - -You can specify the size of the image in an option third parameter: - -` -$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '', array( - 'image_size' => 'medium' - ) ); -` - -If you need data about the image, you may want to use: - -`$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '' );` - -You can specify the size of the image in an option third parameter: - -` -$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '', array( - 'image_size' => 'medium' - ) ); -` - -= List term images associated with a post object = - -When a post is being displayed you may want to display all of the images associated with all of the terms that are associated with the post (a mouthful? Yes indeed!). The `taxonomy-images-list-the-terms` filter does this. Here's what it looks like in its simplest form: - -`print apply_filters( 'taxonomy-images-list-the-terms', '' );` - -This filter accepts an optional third parameter that you can use to customize its output. It is an array which recognizes the following keys: - -* __after__ (string) - Text to append to the output. Default value is a closing unordered list element. - -* __after_image__ (string) - Text to append to each image. Default value is a closing list-item element. - -* __before__ (string) - Text to prepend to the output. Default value is an open unordered list element with an class attribute of "taxonomy-images-the-terms". - -* __before_image__ (string) - Text to prepend to each image. Default value is an open list-item element. - -* __image_size__ (string) - Any registered image size. Values will vary from installation to installation. Image sizes defined in core include: "thumbnail", "medium" and "large". "Fullsize" may also be used to get the unmodified image that was uploaded. Defaults to "thumbnail". - -* __post_id__ (int) - The post to retrieve terms from. Defaults to the ID property of the global $post object. - -* __taxonomy__ (string) - Name of a registered taxonomy to return terms from. Defaults to "category". - -Here's an example of what a fully customized version of this filter might look like: - -` -print apply_filters( 'taxonomy-images-list-the-terms', '', array( - 'after' => '
    ', - 'after_image' => '', - 'before' => '
    ', - 'before_image' => '', - 'image_size' => 'detail', - 'post_id' => 1234, - 'taxonomy' => 'post_tag', - ) ); -` - -= Working with all terms of a given taxonomy = - -You will want to use the 'taxonomy-images-get-terms' filter. This filter is basically a wrapper for WordPress core function [get_terms()](http://codex.wordpress.org/Function_Reference/get_terms). It will return an array of enhanced term objects: each term object will have a custom property named image_id which is an integer representing the database ID of the image associated with the term. This filter can be used to create custom lists of terms. Here's what it's default useage looks like: - -`$terms = apply_filters( 'taxonomy-images-get-terms', '' );` - -Here is what php's print_r() function may return: - -` -Array -( - [0] => stdClass Object - ( - [term_id] => 8 - [name] => Pirate - [slug] => pirate - [term_group] => 0 - [term_taxonomy_id] => 8 - [taxonomy] => category - [description] => Pirates live in the ocean and ride around on boats. - [parent] => 0 - [count] => 1 - [image_id] => 44 - ) -) -` - -As you can see, all of the goodness of get_terms() is there with an added bonus: the image_id parameter! - -This filter recognizes an optional third parameter which is an array of arguments that can be used to modify its output: - -* __cache_images__ (bool) If this value is true all assocaite images will be queried for and cached for later use in various template tags. If it is set to false, this query will be suppressed. Do not set this value to false unless you have a really good reason for doing so :) Default value is true. - -* __having_images__ (bool) If this value is true then only terms that have associated images will be returned. Setting it to false will return all terms. Default value is true. - -* __taxonomy__ (string) Name of a registered taxonomy to return terms from. Multiple taxonomies may be specified by separating each name by a comma. Defaults to "category". - -* __term_args__ (array) Arguments to pass to [get_terms()](http://codex.wordpress.org/Function_Reference/get_terms) as the second parameter. Default value is an empty array. - -Here's and example of a simple custom loop that you can make to display all term images: - -` -$terms = apply_filters( 'taxonomy-images-get-terms', '' ); -if ( ! empty( $terms ) ) { - print ''; -} -` - -= Support = - -If you have questions about integrating this plugin into your site, please [add a new thread to the WordPress Support Forum](http://wordpress.org/tags/taxonomy-images?forum_id=10#postform). I try to answer these, but I may not always be able to. In the event that I cannot there may be someone else who can help. - -= Bugs, Suggestions = - -Development of this plugin is hosted in a public repository on [Github](https://github.com/mfields/Taxonomy-Images). If you find a bug in this plugin or have a suggestion to make it better, please [create a new issue](https://github.com/mfields/Taxonomy-Images/issues/new) - -= Hook it up yo! = - -If you have fallen in love with this plugin and would not be able to sleep without helping out in some way, please see the following list of ways that you can _hook it up!_: - -* __Rate it!__ - Use the star tool on the right-hand sidebar of the [homepage](http://wordpress.org/extend/plugins/taxonomy-images/). - -* __Let me know if it works__ - Use the _Compatibility_ widget on the [homepage](http://wordpress.org/extend/plugins/taxonomy-images/) to let everyone know that the current version works with your version of WordPress. - -* __Do you Twitter?__ Help promote by using this shortlink: [http://bit.ly/taxonomy-images](http://bit.ly/taxonomy-images) - -* __Are you a writer?__ Help promote by writing an article on your website about this plugin. - -* __Are you Super-Wicked-Awesome?__ If so, you can always [make a donation](http://wordpress.mfields.org/donate/). - -= Need More Taxonomy Plugins? = -I've released a handfull of plugins dealing with taxonomies. Please see my [plugin page](http://wordpress.org/extend/plugins/profile/mfields) for more info. - -==Installation== - -1. Download -1. Unzip the package and upload to your /wp-content/plugins/ directory. -1. Log into WordPress and navigate to the "Plugins" panel. -1. Activate the plugin. -1. Click the "Taxonomy Images" link under the Settings section in the admin menu. There you can select the taxonomies that you would like to add image support for. - -== Upgrade Notice == - -= 0.7 = -Complete rewrite. Better everything. Many bug fixes. - -==Changelog== - -= 0.7.3 = -* Fixed the delete image button on edit-terms.php. -* Better escaping. -* Introduced pot file and languages directory. - -= 0.7.2 = -* Return data for fulsize images in archive views. [See this thread](http://wordpress.org/support/topic/image-size-full). - -= 0.7.1 = -* Remove unused link code which is throwing an error when no taxonomies support images. - -= 0.7 = -* No longer breaks display of the [Better Plugin Compatibility Control](http://wordpress.org/extend/plugins/better-plugin-compatibility-control/) plugin. -* Created a custom filter interface for plugin and theme integration. -* Lots of inline documentation added. -* Added custom notices if plugin is used in an unsupported way. -* No notices generated by PHP or WordPress. -* Deprecated function calls removed. -* Security updates. -* All strings are now internationalized. -* Add image to term functionality mimics "Add Featured Image". -* Taxonomy modal button now available in search + upload states. -* Image interface has been added to single term edit screen. -* Users can now choose which taxonomys have image support. -* All functions are now private. -* Shortcode deprecated. -* All global variables and constants have been removed or deprecated. - -= 0.6 = -* Never released. -* Completely recoded. - -= 0.5 = -* __UPDATE:__ Direct link to upload new files from edit-tag.php has been introduced. -* __UPDATE:__ Ability to create an image/term association immediately after upload has been introduced. -* __UPDATE:__ Users can now delete image/term associations. -* __UPDATE:__ Created standalone javascript files - removed inline scripts. -* __UPDATE:__ Obsesive compulsive syntax modifications. -* __UPDATE:__ Localization for strings - still need to "fine-tooth-comb" this. -* __UPDATE:__ Removed all debug functions. - -= 0.4.4 = -* __BUGFIX:__ get_image_html() Now populates the image's alt attribute with appropriate data. Props to [jaygoldman](http://wordpress.org/support/profile/jaygoldman). - -= 0.4.3 = -* __UPDATE:__ Support for WordPress 3.0 has been added. Support for all beta versions of 3.0 has been dropped. -* __COMPAT:__ Removed use of deprecated function is_taxonomy() - props to [anointed](http://profiles.wordpress.org/users/anointed). -* __COMPAT:__ Included a definition for taxonomy_exists() function for backwards compatibility with 2.9 branch. This function is new in WordPress version 3.0. - -= 0.4.2 = -* __UPDATE:__ Changed button name from "Category" to "Taxonomy". -* __UPDATE:__ Support for 2.9 branch has been added again. - -= 0.4.1 = -* __UPDATE:__ Added support for dynamic taxonomy hooks for _tag_row() -* __BROKEN:__ Support for 2.9 branch has been temporarily removed. - -= 0.4 = -* __BUGFIX:__ get_thumb() now returns the fullsize url if there is no appropriate intermediate image. -* __UPDATE:__ Added "taxonomy_images_shortcode". - -= 0.3 = -* __COMPAT:__ Changed the firing order of every hook untilizing the 'category_rows' method to 15. This allows this plugin to be compatible with [Reveal IDs for WP Admin](http://wordpress.org/extend/plugins/reveal-ids-for-wp-admin-25/). Thanks to [Peter Kahoun](http://profiles.wordpress.org/kahi/) -* __COMPAT:__ Added Version check for PHP5. -* __UPDATE:__ `$settings` and `$locale` are now public properties. -* __UPDATE:__ Object name changed to: $taxonomy_images_plugin. -* __UPDATE:__ Added argument $term_tax_id to both print_image_html() and get_image_html(). -* __BUGFIX:__ Deleted the register_deactivation_hook() function -> sorry to all 8 who downloaded this plugin so far :) - -= 0.2 = -* Original Release - Works With: wp 2.9.1. \ No newline at end of file diff --git a/includes/taxonomy-images/taxonomy-images.php b/includes/taxonomy-images/taxonomy-images.php index 899ce1a..53aac6f 100644 --- a/includes/taxonomy-images/taxonomy-images.php +++ b/includes/taxonomy-images/taxonomy-images.php @@ -176,14 +176,11 @@ function sermon_image_plugin_get_image_src( $id ) { if ( is_file( $path ) ) { /* Attempt to create a new downsized version of the original image. */ - $new = wp_get_image_editor( $path, - $detail['size'][0], - $detail['size'][1], - $detail['size'][2] - ); + $new = wp_get_image_editor( $path ); /* Image creation successful. Generate and cache image metadata. Return url. */ if ( ! is_wp_error( $new ) ) { + $new->resize( $detail['size'][0], $detail['size'][1], $detail['size'][2] ); $meta = wp_generate_attachment_metadata( $id, $path ); wp_update_attachment_metadata( $id, $meta ); $img = image_get_intermediate_size( $id, $detail['name'] ); @@ -403,8 +400,12 @@ function sermon_image_plugin_settings_page() { * @access private */ function sermon_image_plugin_control_taxonomies() { - $settings = get_option( 'sermon_image_plugin_settings' ); + $settings = apply_filters( 'sermon_image_plugin_settings', array( + 'taxonomies' => array( 'wpfc_sermon_series', 'wpfc_preacher', 'wpfc_sermon_topics', ) + ) ); + $taxonomies = get_taxonomies( array(), 'objects' ); + foreach ( (array) $taxonomies as $taxonomy ) { if ( ! isset( $taxonomy->name ) ) { continue; @@ -704,7 +705,10 @@ function sermon_image_plugin_get_associations( $refresh = false ) { * @alter 0.7 */ function sermon_image_plugin_add_dynamic_hooks() { - $settings = get_option( 'sermon_image_plugin_settings' ); + $settings = apply_filters( 'sermon_image_plugin_settings', array( + 'taxonomies' => array( 'wpfc_sermon_series', 'wpfc_preacher', 'wpfc_sermon_topics', ) + ) ); + if ( ! isset( $settings['taxonomies'] ) ) { return; } @@ -843,7 +847,7 @@ function sermon_image_plugin_control_image( $term_id, $taxonomy ) { $thickbox_class = version_compare( get_bloginfo( 'version' ), 3.5 ) >= 0 ? '' : 'thickbox'; $o = "\n" . '
    '; - $o .= "\n" . ''; + $o .= "\n" . ''; $o .= "\n" . '' . esc_html__( 'Upload.', 'sermon-manager-for-wordpress' ) . ''; $o .= "\n" . '' . esc_html__( 'Delete', 'sermon-manager-for-wordpress' ) . ''; $o .= "\n" . ''; @@ -1018,13 +1022,6 @@ function sermon_image_plugin_activate() { if ( false === $associations ) { add_option( 'sermon_image_plugin', array() ); } - - $settings = get_option( 'sermon_image_plugin_settings' ); - if ( false === $settings ) { - add_option( 'sermon_image_plugin_settings', array( - 'taxonomies' => array() - ) ); - } } register_activation_hook( __FILE__, 'sermon_image_plugin_activate' ); @@ -1044,7 +1041,10 @@ function sermon_image_plugin_is_screen_active() { return false; } - $settings = get_option( 'sermon_image_plugin_settings' ); + $settings = apply_filters( 'sermon_image_plugin_settings', array( + 'taxonomies' => array( 'wpfc_sermon_series', 'wpfc_preacher', 'wpfc_sermon_topics', ) + ) ); + if ( ! isset( $settings['taxonomies'] ) ) { return false; } @@ -1168,7 +1168,9 @@ function sermon_image_plugin_check_taxonomy( $taxonomy, $filter ) { return false; } - $settings = get_option( 'sermon_image_plugin_settings' ); + $settings = apply_filters( 'sermon_image_plugin_settings', array( + 'taxonomies' => array( 'wpfc_sermon_series', 'wpfc_preacher', 'wpfc_sermon_topics', ) + ) ); if ( ! isset( $settings['taxonomies'] ) ) { trigger_error( wp_sprintf( esc_html__( 'No taxonomies have image support. %1$s', 'sermon-manager-for-wordpress' ), sermon_images_plugin_settings_page_link() ) ); @@ -1299,8 +1301,8 @@ function sermon_images_admin_enqueue_scripts() { wp_localize_script( 'sermon-images-media-modal', 'taxonomyImagesMediaModal', array( 'wp_media_post_id' => 0, 'attachment_id' => 0, - 'uploader_title' => wp_sprintf( esc_html__( 'Set %s’s image', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? : esc_html__ ( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'uploader_button_text' => wp_sprintf( esc_html__( 'Set %s’s image', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? : esc_html__ ( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'uploader_title' => wp_sprintf( esc_html__( 'Set %s’s image', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ?: esc_html__( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'uploader_button_text' => wp_sprintf( esc_html__( 'Set %s’s image', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ?: esc_html__( 'Preacher', 'sermon-manager-for-wordpress' ) ), 'series_title' => esc_html__( 'Set Series image', 'sermon-manager-for-wordpress' ), 'series_button_text' => esc_html__( 'Set Series image', 'sermon-manager-for-wordpress' ), 'default_img_src' => sermon_image_plugin_url( 'default.png' ) diff --git a/includes/template-tags.php b/includes/template-tags.php index 2125ebd..680d3fc 100755 --- a/includes/template-tags.php +++ b/includes/template-tags.php @@ -119,13 +119,13 @@ function render_wpfc_sermon_archive() {

    ', ' ' ); - echo the_terms( $post->ID, 'wpfc_service_type', ' (', ' ', ')' ); + the_terms( $post->ID, 'wpfc_service_type', ' (', ' ', ')' ); ?>

    ' . __( 'Bible Text: ', 'sermon-manager-for-wordpress' ), ' | ' ); - echo the_terms( $post->ID, 'wpfc_preacher', '', ' ', '' ); - echo the_terms( $post->ID, 'wpfc_sermon_series', '

    ' . __( 'Series: ', 'sermon-manager-for-wordpress' ), ' ', '

    ' ); + the_terms( $post->ID, 'wpfc_preacher', '', ' ', '' ); + the_terms( $post->ID, 'wpfc_sermon_series', '

    ' . __( 'Series: ', 'sermon-manager-for-wordpress' ), ' ', '

    ' ); ?>

    @@ -145,10 +145,7 @@ function render_wpfc_sermon_archive() { * @since 2.5.0 added $args */ function render_wpfc_sorting( $args = array() ) { - // reset values - $hidden = array(); - - $action = get_site_url() . '/' . ( SermonManager::getOption( 'common_base_slug' ) ? ( '/' . ( SermonManager::getOption( 'archive_slug' ) ?: 'sermons' ) ) : '' ); + $action = get_site_url() . '/' . ( SermonManager::getOption( 'common_base_slug' ) ? ( SermonManager::getOption( 'archive_slug' ) ?: 'sermons' ) : '' ); // Filters HTML fields data $filters = array( @@ -421,7 +418,7 @@ function wpfc_sermon_single( $return = false, $post = '' ) { - ID, 'wpfc_sermon_topics', '

    ' . __( 'Sermon Topics: ', 'sermon-manager-for-wordpress' ), ',', '

    ' ); ?> + ID, 'wpfc_sermon_topics', '

    ' . __( 'Sermon Topics: ', 'sermon-manager-for-wordpress' ), ',', '

    ' ); ?>
    ', ' ' ); - echo the_terms( $post->ID, 'wpfc_service_type', ' (', ' ', ')' ); + the_terms( $post->ID, 'wpfc_service_type', ' (', ' ', ')' ); ?>

    ' . __( 'Bible Text: ', 'sermon-manager-for-wordpress' ), ' | ' ); - echo the_terms( $post->ID, 'wpfc_preacher', '', ', ', '' ); - echo the_terms( $post->ID, 'wpfc_sermon_series', '

    ' . __( 'Series: ', 'sermon-manager-for-wordpress' ), ' ', '

    ' ); + the_terms( $post->ID, 'wpfc_preacher', '', ', ', '' ); + the_terms( $post->ID, 'wpfc_sermon_series', '

    ' . __( 'Series: ', 'sermon-manager-for-wordpress' ), ' ', '

    ' ); ?>

    @@ -579,12 +576,95 @@ function wpfc_get_term_dropdown( $taxonomy, $default = '' ) { // reset var $html = ''; - foreach ( - get_terms( array( - 'taxonomy' => $taxonomy, - 'hide_empty' => false, // todo: add option to disable/enable this globally - ) ) as $term - ) { + $terms = get_terms( array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, // todo: add option to disable/enable this globally + ) ); + + if ( $taxonomy === 'wpfc_bible_book' ) { + // book order + $books = array( + 'Genesis', + 'Exodus', + 'Leviticus', + 'Numbers', + 'Deuteronomy', + 'Joshua', + 'Judges', + 'Ruth', + '1 Samuel', + '2 Samuel', + '1 Kings', + '2 Kings', + '1 Chronicles', + '2 Chronicles', + 'Ezra', + 'Nehemiah', + 'Esther', + 'Job', + 'Psalm', + 'Proverbs', + 'Ecclesiastes', + 'Song of Songs', + 'Isaiah', + 'Jeremiah', + 'Lamentations', + 'Ezekiel', + 'Daniel', + 'Hosea', + 'Joel', + 'Amos', + 'Obadiah', + 'Jonah', + 'Micah', + 'Nahum', + 'Habakkuk', + 'Zephaniah', + 'Haggai', + 'Zechariah', + 'Malachi', + 'Matthew', + 'Mark', + 'Luke', + 'John', + 'Acts', + 'Romans', + '1 Corinthians', + '2 Corinthians', + 'Galatians', + 'Ephesians', + 'Philippians', + 'Colossians', + '1 Thessalonians', + '2 Thessalonians', + '1 Timothy', + '2 Timothy', + 'Titus', + 'Philemon', + 'Hebrews', + 'James', + '1 Peter', + '2 Peter', + '1 John', + '2 John', + '3 John', + 'Jude', + 'Revelation', + 'Topical', + ); + + // assign every book a number + foreach ( $terms as $term ) { + $ordered_terms[ array_search( $term->name, $books ) ] = $term; + } + + // order the numbers (books) + ksort( $ordered_terms ); + + $terms = $ordered_terms; + } + + foreach ( $terms as $term ) { $html .= ''; } diff --git a/includes/types-taxonomies.php b/includes/types-taxonomies.php deleted file mode 100644 index 6b9d5d1..0000000 --- a/includes/types-taxonomies.php +++ /dev/null @@ -1,408 +0,0 @@ -slug; - - wp_set_object_terms( $post_ID, $service_type, 'wpfc_service_type' ); - } - - return $post; - } -} - -/* - * Creation of Sermon Post Types and Taxonomies - * Also all meta boxes - */ - -// Determine the correct slug name based on options -function generate_wpfc_slug( $slug_name = null ) { - if ( trim( \SermonManager::getOption( 'archive_slug' ) ) === '' ) { - $archive_slug = 'sermons'; - } else { - $archive_slug = \SermonManager::getOption( 'archive_slug' ); - } - - if ( ! isset( $slug_name ) ) { - return array( 'slug' => $archive_slug, 'with_front' => false ); - } - - if ( \SermonManager::getOption( 'common_base_slug' ) ) { - return array( 'slug' => $archive_slug . "/" . $slug_name, 'with_front' => false ); - } else { - return array( 'slug' => $slug_name, 'with_front' => false ); - } -} - -// Create sermon Custom Post Type -function create_wpfc_sermon_types() { - - $labels = array( - 'name' => __( 'Sermons', 'sermon-manager-for-wordpress' ), - 'singular_name' => __( 'Sermon', 'sermon-manager-for-wordpress' ), - 'add_new' => __( 'Add New', 'sermon-manager-for-wordpress' ), - 'add_new_item' => __( 'Add New Sermon', 'sermon-manager-for-wordpress' ), - 'edit_item' => __( 'Edit Sermon', 'sermon-manager-for-wordpress' ), - 'new_item' => __( 'New Sermon', 'sermon-manager-for-wordpress' ), - 'view_item' => __( 'View Sermon', 'sermon-manager-for-wordpress' ), - 'search_items' => __( 'Search Sermons', 'sermon-manager-for-wordpress' ), - 'not_found' => __( 'No sermons found', 'sermon-manager-for-wordpress' ), - 'not_found_in_trash' => __( 'No sermons found in Trash', 'sermon-manager-for-wordpress' ), - 'menu_name' => __( 'Sermons', 'sermon-manager-for-wordpress' ), - ); - - $args = array( - 'labels' => $labels, - 'public' => true, - 'publicly_queryable' => true, - 'show_ui' => true, - 'show_in_menu' => true, - 'query_var' => true, - 'menu_icon' => SM_URL . 'includes/img/sm-icon.svg', - 'capability_type' => 'post', - 'has_archive' => true, - 'rewrite' => generate_wpfc_slug(), - 'hierarchical' => false, - 'supports' => array( 'title', 'comments', 'thumbnail', 'entry-views' ) - ); - register_post_type( 'wpfc_sermon', $args ); -} - -// Create new taxonomies: preachers, sermon series, bible books & topics -function create_wpfc_sermon_taxonomies() { - - //Preachers - $labels = array( - 'name' => \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ), - 'singular_name' => \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ), - 'menu_name' => __( 'Preachers', 'sermon-manager-for-wordpress' ), - 'search_items' => wp_sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'popular_items' => wp_sprintf( __( 'Most frequent %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'all_items' => wp_sprintf( __( 'All %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ) ), - 'edit_item' => wp_sprintf( __( 'Edit %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'update_item' => wp_sprintf( __( 'Update %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'add_new_item' => wp_sprintf( __( 'Add new %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'new_item_name' => wp_sprintf( __( 'New %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'separate_items_with_commas' => wp_sprintf( __( 'Separate multiple %s with commas', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ) ), - 'add_or_remove_items' => wp_sprintf( __( 'Add or remove %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), - 'choose_from_most_used' => wp_sprintf( __( 'Choose from most frequent %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ) ), - 'parent_item' => null, - 'parent_item_colon' => null, - ); - - register_taxonomy( 'wpfc_preacher', 'wpfc_sermon', array( - 'hierarchical' => false, - 'labels' => $labels, - 'show_ui' => true, - 'query_var' => true, - 'rewrite' => generate_wpfc_slug( \SermonManager::getOption( 'preacher_label' ) ? sanitize_title( \SermonManager::getOption( 'preacher_label' ) ) : 'preacher' ), - ) ); - - //Sermon Series - $labels = array( - 'name' => __( 'Sermon Series', 'sermon-manager-for-wordpress' ), - 'singular_name' => __( 'Sermon Series', 'sermon-manager-for-wordpress' ), - 'menu_name' => __( 'Sermon Series', 'sermon-manager-for-wordpress' ), - 'search_items' => __( 'Search sermon series', 'sermon-manager-for-wordpress' ), - 'popular_items' => __( 'Most frequent sermon series', 'sermon-manager-for-wordpress' ), - 'all_items' => __( 'All sermon series', 'sermon-manager-for-wordpress' ), - 'edit_item' => __( 'Edit sermon series', 'sermon-manager-for-wordpress' ), - 'update_item' => __( 'Update sermon series', 'sermon-manager-for-wordpress' ), - 'add_new_item' => __( 'Add new sermon series', 'sermon-manager-for-wordpress' ), - 'new_item_name' => __( 'New sermon series name', 'sermon-manager-for-wordpress' ), - 'separate_items_with_commas' => __( 'Separate sermon series with commas', 'sermon-manager-for-wordpress' ), - 'add_or_remove_items' => __( 'Add or remove sermon series', 'sermon-manager-for-wordpress' ), - 'choose_from_most_used' => __( 'Choose from most used sermon series', 'sermon-manager-for-wordpress' ), - 'parent_item' => null, - 'parent_item_colon' => null, - ); - - register_taxonomy( 'wpfc_sermon_series', 'wpfc_sermon', array( - 'hierarchical' => false, - 'labels' => $labels, - 'show_ui' => true, - 'query_var' => true, - 'rewrite' => generate_wpfc_slug( 'series' ), - ) ); - - //Sermon Topics - $labels = array( - 'name' => __( 'Sermon Topics', 'sermon-manager-for-wordpress' ), - 'singular_name' => __( 'Sermon Topics', 'sermon-manager-for-wordpress' ), - 'menu_name' => __( 'Sermon Topics', 'sermon-manager-for-wordpress' ), - 'search_items' => __( 'Search sermon topics', 'sermon-manager-for-wordpress' ), - 'popular_items' => __( 'Most popular sermon topics', 'sermon-manager-for-wordpress' ), - 'all_items' => __( 'All sermon topics', 'sermon-manager-for-wordpress' ), - 'edit_item' => __( 'Edit sermon topic', 'sermon-manager-for-wordpress' ), - 'update_item' => __( 'Update sermon topic', 'sermon-manager-for-wordpress' ), - 'add_new_item' => __( 'Add new sermon topic', 'sermon-manager-for-wordpress' ), - 'new_item_name' => __( 'New sermon topic', 'sermon-manager-for-wordpress' ), - 'separate_items_with_commas' => __( 'Separate sermon topics with commas', 'sermon-manager-for-wordpress' ), - 'add_or_remove_items' => __( 'Add or remove sermon topics', 'sermon-manager-for-wordpress' ), - 'choose_from_most_used' => __( 'Choose from most used sermon topics', 'sermon-manager-for-wordpress' ), - 'parent_item' => null, - 'parent_item_colon' => null, - ); - - register_taxonomy( 'wpfc_sermon_topics', 'wpfc_sermon', array( - 'hierarchical' => false, - 'labels' => $labels, - 'show_ui' => true, - 'query_var' => true, - 'rewrite' => generate_wpfc_slug( 'topics' ), - ) ); - - //Books of the Bible - $labels = array( - 'name' => __( 'Book of the Bible', 'sermon-manager-for-wordpress' ), - 'singular_name' => __( 'Book of the Bible', 'sermon-manager-for-wordpress' ), - 'menu_name' => __( 'Book of the Bible', 'sermon-manager-for-wordpress' ), - 'search_items' => __( 'Search books of the Bible', 'sermon-manager-for-wordpress' ), - 'popular_items' => __( 'Most popular books of the Bible', 'sermon-manager-for-wordpress' ), - 'all_items' => __( 'All books of the Bible', 'sermon-manager-for-wordpress' ), - 'edit_item' => __( 'Edit book of the Bible', 'sermon-manager-for-wordpress' ), - 'update_item' => __( 'Update book of the Bible', 'sermon-manager-for-wordpress' ), - 'add_new_item' => __( 'Add new books of the Bible', 'sermon-manager-for-wordpress' ), - 'new_item_name' => __( 'New book of the Bible', 'sermon-manager-for-wordpress' ), - 'separate_items_with_commas' => __( 'Separate books of the Bible with commas', 'sermon-manager-for-wordpress' ), - 'add_or_remove_items' => __( 'Add or remove books of the Bible', 'sermon-manager-for-wordpress' ), - 'choose_from_most_used' => __( 'Choose from most used books of the Bible', 'sermon-manager-for-wordpress' ), - 'parent_item' => null, - 'parent_item_colon' => null, - ); - - register_taxonomy( 'wpfc_bible_book', 'wpfc_sermon', array( - 'hierarchical' => false, - 'labels' => $labels, - 'show_ui' => true, - 'query_var' => true, - 'rewrite' => generate_wpfc_slug( 'book' ), - ) ); - - //Service Type - $labels = array( - 'name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), - 'singular_name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), - 'menu_name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), - 'search_items' => __( 'Search service types', 'sermon-manager-for-wordpress' ), - 'popular_items' => __( 'Most popular service types', 'sermon-manager-for-wordpress' ), - 'all_items' => __( 'All service types', 'sermon-manager-for-wordpress' ), - 'edit_item' => __( 'Edit service type', 'sermon-manager-for-wordpress' ), - 'update_item' => __( 'Update service type', 'sermon-manager-for-wordpress' ), - 'add_new_item' => __( 'Add new service types', 'sermon-manager-for-wordpress' ), - 'new_item_name' => __( 'New Service Type', 'sermon-manager-for-wordpress' ), - 'separate_items_with_commas' => __( 'Separate service types with commas', 'sermon-manager-for-wordpress' ), - 'add_or_remove_items' => __( 'Add or remove service types', 'sermon-manager-for-wordpress' ), - 'choose_from_most_used' => __( 'Choose from most used service types', 'sermon-manager-for-wordpress' ), - 'parent_item' => null, - 'parent_item_colon' => null, - ); - - register_taxonomy( 'wpfc_service_type', 'wpfc_sermon', array( - 'hierarchical' => false, - 'labels' => $labels, - 'show_ui' => true, - 'query_var' => true, - 'rewrite' => generate_wpfc_slug( 'service-type' ), - ) ); -} - -/** - * Gets a number of terms and displays them as options - * - * @param string $taxonomy Taxonomy terms to retrieve. Default is category. - * @param string|array $args Optional. get_terms optional arguments - * - * @return array An array of options that matches the CMB2 options array - */ -function cmb2_get_term_options( $taxonomy = 'category' ) { - - $args['taxonomy'] = $taxonomy; - - // $defaults = array( 'taxonomy' => 'category' ); - - $taxonomy = $args['taxonomy']; - - $args = array( - 'hide_empty' => false - ); - - $terms = (array) get_terms( $taxonomy, $args ); - - // Initate an empty array - $term_options = array(); - if ( ! empty( $terms ) ) { - foreach ( $terms as $term ) { - $term_options[ $term->term_id ] = $term->name; - } - } - - return $term_options; -} - -// sanitize the field -add_filter( 'cmb2_sanitize_text_number', 'sm_cmb2_sanitize_text_number', 10, 2 ); -function sm_cmb2_sanitize_text_number( $null, $new ) { - $new = preg_replace( "/[^0-9]/", "", $new ); - - return $new; -} - -// Define the metabox and field configurations -function wpfc_sermon_metaboxes() { - - $cmb = new_cmb2_box( array( - 'id' => 'wpfc_sermon_details', - 'title' => esc_html__( 'Sermon Details', 'sermon-manager-for-wordpress' ), - 'object_types' => array( 'wpfc_sermon', ), // Post type - 'context' => 'normal', - 'priority' => 'high', - 'show_names' => true, // Show field names on the left - // 'cmb_styles' => false, // false to disable the CMB stylesheet - // 'closed' => true, // Keep the metabox closed by default - ) ); - - $date_format = 'm/d/Y'; - if ( \SermonManager::getOption( 'date_format' ) !== '' ) { - switch ( \SermonManager::getOption( 'date_format' ) ) { - case '0': - $date_format = 'm/d/Y'; - break; - case '1': - $date_format = 'd/m/Y'; - break; - case '2': - $date_format = 'Y/m/d'; - break; - case '3': - $date_format = 'Y/d/m'; - break; - } - } - - $cmb->add_field( array( - 'name' => esc_html__( 'Date Preached', 'sermon-manager-for-wordpress' ), - 'desc' => '
    ' . wp_sprintf( esc_html__( 'format: %s', 'sermon-manager-for-wordpress' ), '' . $date_format . '' ), - 'id' => 'sermon_date', - 'type' => 'text_date_timestamp', - 'date_format' => $date_format, - ) ); - - $cmb->add_field( array( - 'name' => esc_html__( 'Service Type', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Select the type of service. Modify service types in Sermons → Service Types.', 'sermon-manager-for-wordpress' ), - 'id' => 'wpfc_service_type', - 'type' => 'select', - 'show_option_none' => true, - 'options' => cmb2_get_term_options( 'wpfc_service_type' ), - ) ); - $cmb->add_field( array( - 'name' => esc_html__( 'Main Bible Passage', 'sermon-manager-for-wordpress' ), - 'desc' => wp_sprintf( esc_html__( 'Enter the Bible passage with the full book names, e.g. %s.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'John 3:16-18', 'sermon-manager-for-wordpress' ) . '' ), - 'id' => 'bible_passage', - 'type' => 'text', - ) ); - $cmb->add_field( array( - 'name' => esc_html__( 'Description', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Type a brief description about this sermon, an outline, or a full manuscript', 'sermon-manager-for-wordpress' ), - 'id' => 'sermon_description', - 'type' => 'wysiwyg', - 'options' => array( 'textarea_rows' => 7, 'media_buttons' => true, ), - ) ); - - $cmb2 = new_cmb2_box( array( - 'id' => 'wpfc_sermon_files', - 'title' => esc_html__( 'Sermon Files', 'sermon-manager-for-wordpress' ), - 'object_types' => array( 'wpfc_sermon', ), // Post type - 'context' => 'normal', - 'priority' => 'high', - 'show_names' => true, // Show field names on the left - // 'cmb_styles' => false, // false to disable the CMB stylesheet - // 'closed' => true, // Keep the metabox closed by default - ) ); - $cmb2->add_field( array( - 'name' => esc_html__( 'Location of MP3', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Upload an audio file or enter an URL.', 'sermon-manager-for-wordpress' ), - 'id' => 'sermon_audio', - 'type' => 'file', - 'text' => array( - 'add_upload_file_text' => __( 'Add Sermon Audio', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" - ), - ) ); - $cmb2->add_field( array( - 'name' => esc_html__( 'MP3 Duration', 'sermon-manager-for-wordpress' ), - 'desc' => wp_sprintf( esc_html__( 'Length in %s format (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'hh:mm:ss', 'sermon-manager-for-wordpress' ) . '' ), - 'id' => '_wpfc_sermon_duration', - 'type' => 'text', - ) ); - $cmb2->add_field( array( - 'name' => esc_html__( 'Video Embed Code', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Paste your embed code for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), - 'id' => 'sermon_video', - 'type' => 'textarea_code' - ) ); - $cmb2->add_field( apply_filters( 'sm_cmb2_field_sermon_video_link', array( - 'name' => esc_html__( 'Video Link', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Paste your link for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), - 'id' => 'sermon_video_link', - 'type' => 'text' - ) ) - ); - $cmb2->add_field( array( - 'name' => esc_html__( 'Sermon Notes', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), - 'id' => 'sermon_notes', - 'type' => 'file', - 'text' => array( - 'add_upload_file_text' => __( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" - ), - ) ); - $cmb2->add_field( array( - 'name' => esc_html__( 'Bulletin', 'sermon-manager-for-wordpress' ), - 'desc' => esc_html__( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), - 'id' => 'sermon_bulletin', - 'type' => 'file', - 'text' => array( - 'add_upload_file_text' => __( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" - ), - ) ); - -} - -/** - * Build