diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md
similarity index 100%
rename from CONTRIBUTING.md
rename to .github/CONTRIBUTING.md
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000..6605c9e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,22 @@
+### Expected Behaviour
+
+1.
+
+### Actual Behaviour
+
+1.
+
+### Steps To Reproduce
+
+1.
+
+### Platform
+**Sermon Manager Version:**
+**WordPress Version:**
+**PHP Version:**
+
+### Any Additional Info
+
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..c5e907a
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,17 @@
+## Types of changes
+
+- [ ] Bug fix (non-breaking change which fixes an issue)
+- [ ] New feature (non-breaking change which adds functionality)
+- [ ] Breaking change (fix or feature that would cause existing functionality to change)
+
+## Checklist:
+
+
+- [ ] My code follows the code style of this project. (WPCS)
+- [ ] My change requires a change to the documentation.
+- [ ] I have read the **CONTRIBUTING** document.
+
+
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..71f32cf
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@wpforchurch.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/assets/css/admin-partials/_import-export.scss b/assets/css/admin-partials/_import-export.scss
index d72af0a..975580c 100644
--- a/assets/css/admin-partials/_import-export.scss
+++ b/assets/css/admin-partials/_import-export.scss
@@ -95,16 +95,15 @@
margin-top: 1rem;
}
}
-
+
.wp-upload-form {
display: none;
}
-
+
.import-sniper {
line-height: 1;
vertical-align: middle;
width: 13px;
- display: inline-block;
position: relative;
top: -1px;
display: none;
diff --git a/assets/css/admin-partials/_settings.scss b/assets/css/admin-partials/_settings.scss
index a46a38e..5e19607 100644
--- a/assets/css/admin-partials/_settings.scss
+++ b/assets/css/admin-partials/_settings.scss
@@ -10,6 +10,7 @@
.settings-content {
width: 100%;
+ //noinspection SpellCheckingInspection
#mainform {
border: 1px solid #e8e8e8;
}
diff --git a/assets/css/admin.min.css b/assets/css/admin.min.css
index 93874ea..7465973 100644
--- a/assets/css/admin.min.css
+++ b/assets/css/admin.min.css
@@ -1,2 +1,2 @@
-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;width:100%;text-align:center}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}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .wp-upload-form{display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper{line-height:1;vertical-align:middle;width:13px;display:inline-block;position:relative;top:-1px;display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper img{max-width:100%}body.post-php.post-type-wpfc_sermon #sermon_video_link{width:25em}
+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;width:100%;text-align:center}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}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .wp-upload-form{display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper{line-height:1;vertical-align:middle;width:13px;position:relative;top:-1px;display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper img{max-width:100%}body.post-php.post-type-wpfc_sermon #sermon_video_link{width:25em}
/*# sourceMappingURL=admin.min.css.map */
diff --git a/assets/css/admin.min.css.map b/assets/css/admin.min.css.map
index 18a2909..44da695 100644
--- a/assets/css/admin.min.css.map
+++ b/assets/css/admin.min.css.map
@@ -1,6 +1,6 @@
{
"version": 3,
-"mappings": "AACE,uHAAmC,CACjC,KAAK,CAAE,GAAG,CAGZ,mHAA+B,CAC7B,KAAK,CAAE,GAAG,CAGZ,wDAAc,CACZ,KAAK,CAAE,EAAE,CCVb,oDAAmB,CACjB,aAAa,CAAE,GAAG,CAGpB,gDAAe,CACb,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,GAAG,CAGjB,mDAAkB,CAChB,KAAK,CAAE,IAAI,CAEX,6DAAU,CACR,MAAM,CAAE,iBAAiB,CAG3B,oEAAiB,CACf,OAAO,CAAE,KAAK,CACd,UAAU,CAAE,GAAG,CAGjB,0IAAoC,CAClC,KAAK,CAAE,IAAI,CACX,SAAS,CAAE,KAAK,CAGlB,uEAAoB,CAClB,UAAU,CAAE,KAAK,CACjB,OAAO,CAAE,CAAC,CACV,aAAa,CAAE,iBAAiB,CAEhC,gFAAS,CACP,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,SAAS,CAClB,OAAO,CAAE,YAAY,CACrB,UAAU,CAAE,IAAI,CAChB,WAAW,CAAE,MAAM,CACnB,KAAK,CAAE,IAAI,CACX,SAAS,CAAE,IAAI,CAEf,qQAA2B,CACzB,aAAa,CAAE,cAAc,CAC7B,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,IAAI,CAIpB,wXAA4F,CAC1F,aAAa,CAAE,iBAAiB,CAIpC,2DAAQ,CACN,OAAO,CAAE,sBAAsB,CAC/B,UAAU,CAAE,KAAK,CAIrB,gDAAe,CACb,KAAK,CAAE,GAAG,CACV,SAAS,CAAE,KAAK,CAChB,WAAW,CAAE,IAAI,CAGf,2DAAG,CACD,WAAW,CAAE,KAAK,CAGpB,qEAAa,CACX,UAAU,CAAE,MAAM,CAClB,SAAS,CAAE,MAAM,CACjB,OAAO,CAAE,UACX,CAEA,2DAAG,CACD,eAAe,CAAE,MAAM,CC7E7B,qDAAe,CACb,QAAQ,CAAE,MAAM,CAChB,MAAM,CAAE,IAAI,CAGd,mDAAa,CACX,QAAQ,CAAE,QAAQ,CAElB,sDAAK,CACH,QAAQ,CAAE,QAAQ,CAClB,IAAI,CAAE,GAAG,CACT,GAAG,CAAE,GAAG,CACR,SAAS,CAAE,qBAAqB,CAChC,OAAO,CAAE,CAAC,CACV,KAAK,CAAE,kBAAkB,CACzB,MAAM,CAAE,CAAC,CACT,SAAS,CAAE,MAAM,CACjB,WAAW,CAAE,GAAG,CAChB,cAAc,CAAE,GAAG,CACnB,WAAW,CAAE,oBAAoB,CACjC,cAAc,CAAE,SAAS,CACzB,OAAO,CAAE,CAAC,CACV,UAAU,CAAE,WAAW,CACvB,MAAM,CAAE,OAAO,CACf,KAAK,CAAE,IAAI,CACX,UAAU,CAAE,MAAM,CAIlB,wEAAS,CACP,OAAO,CAAE,EAAE,CACX,UAAU,CAAE,qHAAiI,CAC7I,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,QAAQ,CAAE,QAAQ,CAClB,IAAI,CAAE,CAAC,CACP,GAAG,CAAE,CAAC,CACN,OAAO,CAAE,CAAC,CAIV,0EAAK,CACH,OAAO,CAAE,CAAC,CAGZ,wFAAiB,CACf,cAAc,CAAE,SAAS,CACzB,MAAM,CAAE,SAAS,CAIrB,mEAAE,CACA,KAAK,CAAE,IAAI,CAGb,8EAAa,CACX,MAAM,CAAE,YAAY,CAIxB,oEAAiB,CACf,OAAO,CAAE,CAAC,CAEV,uFAAqB,CACnB,OAAO,CAAE,KAAK,CAGhB,iFAAa,CACX,OAAO,CAAE,IAAI,CACb,KAAK,CAAE,eAAkB,CAG3B,0EAAM,CACJ,UAAU,CAAE,IAAI,CAGlB,qJAAa,CACX,WAAW,CAAE,KAAK,CAGpB,kFAAc,CACZ,GAAG,CAAE,CAAC,CAGR,iFAAa,CACX,SAAS,CAAE,IAAI,CACf,KAAK,CAAE,OAAO,CACd,IAAI,CAAE,CAAC,CACP,GAAG,CAAE,CAAC,CACN,MAAM,CAAE,KAAK,CACb,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,cAAc,CAEtB,2FAAY,CACV,UAAU,CAAE,IAAI,CAIpB,oFAAgB,CACd,OAAO,CAAE,IAAI,CAGf,mFAAe,CACb,WAAW,CAAE,CAAC,CACd,cAAc,CAAE,MAAM,CACtB,KAAK,CAAE,IAAI,CACX,OAAO,CAAE,YAAY,CACrB,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,IAAI,CACT,OAAO,CAAE,IAAI,CACb,uFAAI,CACF,SAAS,CAAE,IAAI,CC/GvB,sDAAmB,CACjB,KAAK,CAAE,IAAI",
+"mappings": "AACE,uHAAmC,CACjC,KAAK,CAAE,GAAG,CAGZ,mHAA+B,CAC7B,KAAK,CAAE,GAAG,CAGZ,wDAAc,CACZ,KAAK,CAAE,EAAE,CCVb,oDAAmB,CACjB,aAAa,CAAE,GAAG,CAGpB,gDAAe,CACb,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,GAAG,CAGjB,mDAAkB,CAChB,KAAK,CAAE,IAAI,CAGX,6DAAU,CACR,MAAM,CAAE,iBAAiB,CAG3B,oEAAiB,CACf,OAAO,CAAE,KAAK,CACd,UAAU,CAAE,GAAG,CAGjB,0IAAoC,CAClC,KAAK,CAAE,IAAI,CACX,SAAS,CAAE,KAAK,CAGlB,uEAAoB,CAClB,UAAU,CAAE,KAAK,CACjB,OAAO,CAAE,CAAC,CACV,aAAa,CAAE,iBAAiB,CAEhC,gFAAS,CACP,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,SAAS,CAClB,OAAO,CAAE,YAAY,CACrB,UAAU,CAAE,IAAI,CAChB,WAAW,CAAE,MAAM,CACnB,KAAK,CAAE,IAAI,CACX,SAAS,CAAE,IAAI,CAEf,qQAA2B,CACzB,aAAa,CAAE,cAAc,CAC7B,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,IAAI,CAIpB,wXAA4F,CAC1F,aAAa,CAAE,iBAAiB,CAIpC,2DAAQ,CACN,OAAO,CAAE,sBAAsB,CAC/B,UAAU,CAAE,KAAK,CAIrB,gDAAe,CACb,KAAK,CAAE,GAAG,CACV,SAAS,CAAE,KAAK,CAChB,WAAW,CAAE,IAAI,CAGf,2DAAG,CACD,WAAW,CAAE,KAAK,CAGpB,qEAAa,CACX,UAAU,CAAE,MAAM,CAClB,SAAS,CAAE,MAAM,CACjB,OAAO,CAAE,UACX,CAEA,2DAAG,CACD,eAAe,CAAE,MAAM,CC9E7B,qDAAe,CACb,QAAQ,CAAE,MAAM,CAChB,MAAM,CAAE,IAAI,CAGd,mDAAa,CACX,QAAQ,CAAE,QAAQ,CAElB,sDAAK,CACH,QAAQ,CAAE,QAAQ,CAClB,IAAI,CAAE,GAAG,CACT,GAAG,CAAE,GAAG,CACR,SAAS,CAAE,qBAAqB,CAChC,OAAO,CAAE,CAAC,CACV,KAAK,CAAE,kBAAkB,CACzB,MAAM,CAAE,CAAC,CACT,SAAS,CAAE,MAAM,CACjB,WAAW,CAAE,GAAG,CAChB,cAAc,CAAE,GAAG,CACnB,WAAW,CAAE,oBAAoB,CACjC,cAAc,CAAE,SAAS,CACzB,OAAO,CAAE,CAAC,CACV,UAAU,CAAE,WAAW,CACvB,MAAM,CAAE,OAAO,CACf,KAAK,CAAE,IAAI,CACX,UAAU,CAAE,MAAM,CAIlB,wEAAS,CACP,OAAO,CAAE,EAAE,CACX,UAAU,CAAE,qHAAiI,CAC7I,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,QAAQ,CAAE,QAAQ,CAClB,IAAI,CAAE,CAAC,CACP,GAAG,CAAE,CAAC,CACN,OAAO,CAAE,CAAC,CAIV,0EAAK,CACH,OAAO,CAAE,CAAC,CAGZ,wFAAiB,CACf,cAAc,CAAE,SAAS,CACzB,MAAM,CAAE,SAAS,CAIrB,mEAAE,CACA,KAAK,CAAE,IAAI,CAGb,8EAAa,CACX,MAAM,CAAE,YAAY,CAIxB,oEAAiB,CACf,OAAO,CAAE,CAAC,CAEV,uFAAqB,CACnB,OAAO,CAAE,KAAK,CAGhB,iFAAa,CACX,OAAO,CAAE,IAAI,CACb,KAAK,CAAE,eAAkB,CAG3B,0EAAM,CACJ,UAAU,CAAE,IAAI,CAGlB,qJAAa,CACX,WAAW,CAAE,KAAK,CAGpB,kFAAc,CACZ,GAAG,CAAE,CAAC,CAGR,iFAAa,CACX,SAAS,CAAE,IAAI,CACf,KAAK,CAAE,OAAO,CACd,IAAI,CAAE,CAAC,CACP,GAAG,CAAE,CAAC,CACN,MAAM,CAAE,KAAK,CACb,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,cAAc,CAEtB,2FAAY,CACV,UAAU,CAAE,IAAI,CAIpB,oFAAgB,CACd,OAAO,CAAE,IAAI,CAGf,mFAAe,CACb,WAAW,CAAE,CAAC,CACd,cAAc,CAAE,MAAM,CACtB,KAAK,CAAE,IAAI,CACX,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,IAAI,CACT,OAAO,CAAE,IAAI,CACb,uFAAI,CACF,SAAS,CAAE,IAAI,CC9GvB,sDAAmB,CACjB,KAAK,CAAE,IAAI",
"sources": ["admin-partials/_all-sermons.scss","admin-partials/_settings.scss","admin-partials/_import-export.scss","admin-partials/_add-edit-sermon.scss"],
"names": [],
"file": "admin.min.css"
diff --git a/assets/css/partials/_archive.scss b/assets/css/partials/_archive.scss
index 5e26442..bd092d9 100644
--- a/assets/css/partials/_archive.scss
+++ b/assets/css/partials/_archive.scss
@@ -17,8 +17,11 @@
&-header {
display: grid;
- grid-template-columns: 70% 30%;
align-items: center;
+
+ &.aside-exists {
+ grid-template-columns: 70% 30%;
+ }
}
&-header-aside {
diff --git a/assets/css/partials/_single.scss b/assets/css/partials/_single.scss
index 67eb2f7..c49b9b0 100644
--- a/assets/css/partials/_single.scss
+++ b/assets/css/partials/_single.scss
@@ -27,6 +27,7 @@
margin: auto;
}
+ //noinspection SpellCheckingInspection
.mejs-video {
margin: 0;
}
@@ -69,17 +70,14 @@
.player-wordpress & {
background: #222;
+ margin-bottom: 1.75em;
svg {
fill: rgb(255, 255, 255);
}
-
- @media screen and (min-width: 77.5em) {
- font-size: 1.9rem;
- margin-bottom: 1.6842em;
- }
}
+ //noinspection SpellCheckingInspection
.player-mediaelement & {
background: #222;
diff --git a/assets/css/sermon.min.css b/assets/css/sermon.min.css
index ee2057a..6acd8bf 100644
--- a/assets/css/sermon.min.css
+++ b/assets/css/sermon.min.css
@@ -1,2 +1,2 @@
-.wpfc-sermon-container #wpfc_sermon_sorting{padding:0;margin:0 0 48px 0}.wpfc-sermon-container #wpfc_sermon_sorting>div{margin:0 8px 4px 0}.wpfc-sermon-container #wpfc_sermon_sorting>div:last-child{margin:0 0 4px 0}.wpfc-sermon-container #wpfc_sermon_sorting form{margin:0}@media (max-width: 700px){.wpfc-sermon-container #wpfc_sermon_sorting>div{width:100%;margin:0 0 12px 0}.wpfc-sermon-container #wpfc_sermon_sorting>div:last-child{margin:0}.wpfc-sermon-container #wpfc_sermon_sorting select{display:block;width:100%;max-width:100%}}.wpfc-sermon-shortcode{margin-bottom:2rem}.wpfc-sermon-image{height:auto;position:relative}.wpfc-sermon-image-img{width:100%;background-size:cover;background-position:center}.wpfc-sermon-header{display:grid;grid-template-columns:70% 30%;align-items:center}.wpfc-sermon-header-aside{text-align:center}.wpfc-sermon-title{margin:0;padding:0}.wpfc-sermon-meta-item{font-size:14px;opacity:.87}.wpfc-sermon-meta-series{margin:0 0 8px 0}.wpfc-sermon-meta-date{margin:8px 0 0}.wpfc-sermon-description{font-size:14px;margin:8px 0 0}.wpfc-sermon-description p{margin:0 0 12px 0}.wpfc-sermon-description p:last-child{margin:0}.wpfc-sermon-audio{margin-top:24px}.wpfc-sermon-footer{margin-top:24px;padding-top:24px;border-top:1px solid #ddd}.wpfc-sermon-footer .wpfc-sermon-meta-item{display:inline-block;position:relative}.wpfc-sermon-footer .wpfc-sermon-meta-item:not(:last-child):after{content:'|';padding:0 4px;color:#ddd}.wpfc-sermon-meta-preacher img{border-radius:50%;width:35px;height:35px;vertical-align:middle;display:inline-block}.wpfc-sermon-meta-preacher>a{text-decoration:none;box-shadow:none;border:0;display:inline-block}.wpfc-sermon-meta-prefix,.wpfc-sermon-meta-text{vertical-align:middle}.wpfc-sermon>.wpfc-sermon-inner{background:white;border:1px solid #ddd}.wpfc-sermon-main{padding:24px}.wpfc-sermon-att-audio,.wpfc-sermon-att-notes,.wpfc-sermon-bulletin{width:auto;height:auto;padding:4px;border:1px solid #efefef;margin-bottom:4px}@media (min-width: 801px){.wpfc-sermon-inner{display:flex;flex-flow:row wrap}.wpfc-sermon-image{flex:0 30%}.wpfc-sermon-image-img{height:100%}.wpfc-sermon-main{flex:1}}@media (max-width: 800px){.wpfc-sermon-image-img{padding-top:56.25%}}.wpfc-sermon-single-header{text-align:center}.wpfc-sermon-single-meta{margin:8px -8px 0 -8px}.wpfc-sermon-single-meta-item{display:inline-block;margin:0 8px;font-size:14px;opacity:.87}.wpfc-sermon-single-meta-date{margin-bottom:8px}.wpfc-sermon-single-title{margin:0;padding:0}.wpfc-sermon-single .wp-video{margin:auto}.wpfc-sermon-single .mejs-video{margin:0}.wpfc-sermon-single mediaelementwrapper>iframe{width:100%;margin-bottom:0;height:100%}.wpfc-sermon-single-media{text-align:center}.wpfc-sermon-single-media>div{margin:24px 0}.wpfc-sermon-single-audio{display:flex;justify-content:center}.wpfc-sermon-single-audio-download{display:flex;align-items:center;flex:none;background:white;padding:0 1.25rem;box-shadow:none;text-decoration:none;outline:none}.player-none .wpfc-sermon-single-audio-download svg{fill:#5d5d5d}.player-wordpress .wpfc-sermon-single-audio-download{background:#222}.player-wordpress .wpfc-sermon-single-audio-download svg{fill:#fff}@media screen and (min-width: 77.5em){.player-wordpress .wpfc-sermon-single-audio-download{font-size:1.9rem;margin-bottom:1.6842em}}.player-mediaelement .wpfc-sermon-single-audio-download{background:#222}.player-mediaelement .wpfc-sermon-single-audio-download:hover{background-color:rgba(51,51,51,0.7)}.player-mediaelement .wpfc-sermon-single-audio-download svg{fill:#fff}.player-plyr .wpfc-sermon-single-audio-download{border:1px solid #dbe3e8;border-left:none;transition:background .3s}.player-plyr .wpfc-sermon-single-audio-download:hover{background:#dbe3e8}.player-plyr .wpfc-sermon-single-audio-download:hover svg{fill:#fff}.wpfc-sermon-single .player-plyr .plyr{flex:1}.wpfc-sermon-single-description{margin-top:24px}.wpfc-sermon-single-description p:first-child{margin-top:0}.wpfc-sermon-single-description p:last-child{margin-bottom:0}.wpfc-sermon-single-attachments{background:#efefef;border:1px solid #ddd;padding:24px;margin-top:24px}.wpfc-sermon-single-attachments #wpfc-attachments strong,.wpfc-sermon-single-attachments #wpfc-attachments a{display:block}.wpfc-sermon-single-attachments #wpfc-attachments p{margin:0}.wpfc-sermon-single-attachments #wpfc-attachments .dashicons{line-height:28px}.wpfc-sermon-single-topics{margin-top:24px}.wpfc-sermon-single-navigation{border-top:1px solid #ddd;margin-top:2rem;padding-top:1rem;display:grid;grid-template-columns:50% 50%}.wpfc-sermon-single-navigation .next-sermon{text-align:right}ul#wpfc_images_grid{display:grid;grid-template-columns:50% 50%;grid-gap:1rem;padding:0}ul#wpfc_images_grid .wpfc_grid_image{display:block}ul#wpfc_images_grid .wpfc_grid_image img{margin-bottom:15px}ul#wpfc_images_grid .wpfc_grid_title{margin:0}.wpfc-sermon-player{vertical-align:middle}.wpfc-sermon-player+.wpfc-sermon-single-audio-download{display:none}
+.wpfc-sermon-container #wpfc_sermon_sorting{padding:0;margin:0 0 48px 0}.wpfc-sermon-container #wpfc_sermon_sorting>div{margin:0 8px 4px 0}.wpfc-sermon-container #wpfc_sermon_sorting>div:last-child{margin:0 0 4px 0}.wpfc-sermon-container #wpfc_sermon_sorting form{margin:0}@media (max-width: 700px){.wpfc-sermon-container #wpfc_sermon_sorting>div{width:100%;margin:0 0 12px 0}.wpfc-sermon-container #wpfc_sermon_sorting>div:last-child{margin:0}.wpfc-sermon-container #wpfc_sermon_sorting select{display:block;width:100%;max-width:100%}}.wpfc-sermon-shortcode{margin-bottom:2rem}.wpfc-sermon-image{height:auto;position:relative}.wpfc-sermon-image-img{width:100%;background-size:cover;background-position:center}.wpfc-sermon-header{display:grid;align-items:center}.wpfc-sermon-header.aside-exists{grid-template-columns:70% 30%}.wpfc-sermon-header-aside{text-align:center}.wpfc-sermon-title{margin:0;padding:0}.wpfc-sermon-meta-item{font-size:14px;opacity:.87}.wpfc-sermon-meta-series{margin:0 0 8px 0}.wpfc-sermon-meta-date{margin:8px 0 0}.wpfc-sermon-description{font-size:14px;margin:8px 0 0}.wpfc-sermon-description p{margin:0 0 12px 0}.wpfc-sermon-description p:last-child{margin:0}.wpfc-sermon-audio{margin-top:24px}.wpfc-sermon-footer{margin-top:24px;padding-top:24px;border-top:1px solid #ddd}.wpfc-sermon-footer .wpfc-sermon-meta-item{display:inline-block;position:relative}.wpfc-sermon-footer .wpfc-sermon-meta-item:not(:last-child):after{content:'|';padding:0 4px;color:#ddd}.wpfc-sermon-meta-preacher img{border-radius:50%;width:35px;height:35px;vertical-align:middle;display:inline-block}.wpfc-sermon-meta-preacher>a{text-decoration:none;box-shadow:none;border:0;display:inline-block}.wpfc-sermon-meta-prefix,.wpfc-sermon-meta-text{vertical-align:middle}.wpfc-sermon>.wpfc-sermon-inner{background:white;border:1px solid #ddd}.wpfc-sermon-main{padding:24px}.wpfc-sermon-att-audio,.wpfc-sermon-att-notes,.wpfc-sermon-bulletin{width:auto;height:auto;padding:4px;border:1px solid #efefef;margin-bottom:4px}@media (min-width: 801px){.wpfc-sermon-inner{display:flex;flex-flow:row wrap}.wpfc-sermon-image{flex:0 30%}.wpfc-sermon-image-img{height:100%}.wpfc-sermon-main{flex:1}}@media (max-width: 800px){.wpfc-sermon-image-img{padding-top:56.25%}}.wpfc-sermon-single-header{text-align:center}.wpfc-sermon-single-meta{margin:8px -8px 0 -8px}.wpfc-sermon-single-meta-item{display:inline-block;margin:0 8px;font-size:14px;opacity:.87}.wpfc-sermon-single-meta-date{margin-bottom:8px}.wpfc-sermon-single-title{margin:0;padding:0}.wpfc-sermon-single .wp-video{margin:auto}.wpfc-sermon-single .mejs-video{margin:0}.wpfc-sermon-single mediaelementwrapper>iframe{width:100%;margin-bottom:0;height:100%}.wpfc-sermon-single-media{text-align:center}.wpfc-sermon-single-media>div{margin:24px 0}.wpfc-sermon-single-audio{display:flex;justify-content:center}.wpfc-sermon-single-audio-download{display:flex;align-items:center;flex:none;background:white;padding:0 1.25rem;box-shadow:none;text-decoration:none;outline:none}.player-none .wpfc-sermon-single-audio-download svg{fill:#5d5d5d}.player-wordpress .wpfc-sermon-single-audio-download{background:#222;margin-bottom:1.75em}.player-wordpress .wpfc-sermon-single-audio-download svg{fill:#fff}.player-mediaelement .wpfc-sermon-single-audio-download{background:#222}.player-mediaelement .wpfc-sermon-single-audio-download:hover{background-color:rgba(51,51,51,0.7)}.player-mediaelement .wpfc-sermon-single-audio-download svg{fill:#fff}.player-plyr .wpfc-sermon-single-audio-download{border:1px solid #dbe3e8;border-left:none;transition:background .3s}.player-plyr .wpfc-sermon-single-audio-download:hover{background:#dbe3e8}.player-plyr .wpfc-sermon-single-audio-download:hover svg{fill:#fff}.wpfc-sermon-single .player-plyr .plyr{flex:1}.wpfc-sermon-single-description{margin-top:24px}.wpfc-sermon-single-description p:first-child{margin-top:0}.wpfc-sermon-single-description p:last-child{margin-bottom:0}.wpfc-sermon-single-attachments{background:#efefef;border:1px solid #ddd;padding:24px;margin-top:24px}.wpfc-sermon-single-attachments #wpfc-attachments strong,.wpfc-sermon-single-attachments #wpfc-attachments a{display:block}.wpfc-sermon-single-attachments #wpfc-attachments p{margin:0}.wpfc-sermon-single-attachments #wpfc-attachments .dashicons{line-height:28px}.wpfc-sermon-single-topics{margin-top:24px}.wpfc-sermon-single-navigation{border-top:1px solid #ddd;margin-top:2rem;padding-top:1rem;display:grid;grid-template-columns:50% 50%}.wpfc-sermon-single-navigation .next-sermon{text-align:right}ul#wpfc_images_grid{display:grid;grid-template-columns:50% 50%;grid-gap:1rem;padding:0}ul#wpfc_images_grid .wpfc_grid_image{display:block}ul#wpfc_images_grid .wpfc_grid_image img{margin-bottom:15px}ul#wpfc_images_grid .wpfc_grid_title{margin:0}.wpfc-sermon-player{vertical-align:middle}
/*# sourceMappingURL=sermon.min.css.map */
diff --git a/assets/css/sermon.min.css.map b/assets/css/sermon.min.css.map
index f2492ab..5e19b16 100644
--- a/assets/css/sermon.min.css.map
+++ b/assets/css/sermon.min.css.map
@@ -1,6 +1,6 @@
{
"version": 3,
-"mappings": "AACE,2CAAqB,CACnB,OAAO,CAAE,CAAC,CACV,MAAM,CAAE,UAAU,CAElB,+CAAM,CACJ,MAAM,CAAE,WAAW,CAGrB,0DAAiB,CACf,MAAM,CAAE,SAAS,CAGnB,gDAAK,CACH,MAAM,CAAE,CAAC,CAKf,yBAA0B,CAEtB,+CAAM,CACJ,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,UAAU,CAGpB,0DAAiB,CACf,MAAM,CAAE,CAAC,CAGX,kDAAO,CACL,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CACX,SAAS,CAAE,IAAI,EC/BnB,sBAAY,CACV,aAAa,CAAE,IAAI,CAGrB,kBAAQ,CACN,MAAM,CAAE,IAAI,CACZ,QAAQ,CAAE,QAAQ,CAGpB,sBAAY,CACV,KAAK,CAAE,IAAI,CACX,eAAe,CAAE,KAAK,CACtB,mBAAmB,CAAE,MAAM,CAG7B,mBAAS,CACP,OAAO,CAAE,IAAI,CACb,qBAAqB,CAAE,OAAO,CAC9B,WAAW,CAAE,MAAM,CAGrB,yBAAe,CACb,UAAU,CAAE,MAAM,CAGpB,kBAAQ,CACN,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,CAAC,CAGZ,sBAAY,CACV,SAAS,CAAE,IAAI,CACf,OAAO,CAAE,GAAG,CAGd,wBAAc,CACZ,MAAM,CAAE,SAAS,CAGnB,sBAAY,CACV,MAAM,CAAE,OAAO,CAGjB,wBAAc,CACZ,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,OAAO,CAEf,0BAAE,CACA,MAAM,CAAE,UAAU,CAElB,qCAAa,CACX,MAAM,CAAE,CAAC,CAKf,kBAAQ,CACN,UAAU,CAAE,IAAI,CAGlB,mBAAS,CACP,UAAU,CAAE,IAAI,CAChB,WAAW,CAAE,IAAI,CACjB,UAAU,CAAE,cAAc,CAE1B,0CAAuB,CACrB,OAAO,CAAE,YAAY,CACrB,QAAQ,CAAE,QAAQ,CAElB,iEAAyB,CACvB,OAAO,CAAE,GAAG,CACZ,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CAMf,8BAAI,CACF,aAAa,CAAE,GAAG,CAClB,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,cAAc,CAAE,MAAM,CACtB,OAAO,CAAE,YAAY,CAGvB,4BAAI,CACF,eAAe,CAAE,IAAI,CACrB,UAAU,CAAE,IAAI,CAChB,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,YAAY,CAIzB,+CACY,CACV,cAAc,CAAE,MAAM,CAGxB,+BAAqB,CACnB,UAAU,CAAE,KAAK,CACjB,MAAM,CAAE,cAAc,CAGxB,iBAAO,CACL,OAAO,CAAE,IAAI,CAGf,mEAEW,CACT,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,OAAO,CAAE,GAAG,CACZ,MAAM,CAAE,iBAAiB,CACzB,aAAa,CAAE,GAAG,CAItB,yBAA0B,CAEtB,kBAAQ,CACN,OAAO,CAAE,IAAI,CACb,SAAS,CAAE,QAAQ,CAGrB,kBAAQ,CACN,IAAI,CAAE,KAAK,CAGb,sBAAY,CACV,MAAM,CAAE,IAAI,CAGd,iBAAO,CACL,IAAI,CAAE,CAAC,EAKb,yBAAyB,CACvB,sBAAuB,CACrB,WAAW,CAAE,MAAM,EC/IrB,0BAAS,CACP,UAAU,CAAE,MAAM,CAGpB,wBAAO,CACL,MAAM,CAAE,eAAe,CAGzB,6BAAY,CACV,OAAO,CAAE,YAAY,CACrB,MAAM,CAAE,KAAK,CACb,SAAS,CAAE,IAAI,CACf,OAAO,CAAE,GAAG,CAGd,6BAAY,CACV,aAAa,CAAE,GAAG,CAGpB,yBAAQ,CACN,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,CAAC,CAGZ,6BAAU,CACR,MAAM,CAAE,IAAI,CAGd,+BAAY,CACV,MAAM,CAAE,CAAC,CAIX,8CAA6B,CAC3B,KAAK,CAAE,IAAI,CACX,aAAa,CAAE,CAAC,CAChB,MAAM,CAAE,IAAI,CAGd,yBAAQ,CACN,UAAU,CAAE,MAAM,CAElB,6BAAM,CACJ,MAAM,CAAE,MAAM,CAIlB,yBAAQ,CACN,OAAO,CAAE,IAAI,CACb,eAAe,CAAE,MAAM,CAGzB,kCAAiB,CACf,OAAO,CAAE,IAAI,CACb,WAAW,CAAE,MAAM,CACnB,IAAI,CAAE,IAAI,CACV,UAAU,CAAE,KAAK,CACjB,OAAO,CAAE,SAAS,CAClB,UAAU,CAAE,IAAI,CAChB,eAAe,CAAE,IAAI,CACrB,OAAO,CAAE,IAAI,CAGX,mDAAI,CACF,IAAI,CAAE,OAAe,CAIzB,oDAAoB,CAClB,UAAU,CAAE,IAAI,CAEhB,wDAAI,CACF,IAAI,CAAE,IAAkB,CAG1B,qCAAsC,CAPxC,oDAAoB,CAQhB,SAAS,CAAE,MAAM,CACjB,aAAa,CAAE,QAAQ,EAI3B,uDAAuB,CACrB,UAAU,CAAE,IAAI,CAEhB,6DAAQ,CACN,gBAAgB,CAAE,kBAAqB,CAGzC,2DAAI,CACF,IAAI,CAAE,IAAkB,CAI5B,+CAAe,CACb,MAAM,CAAE,iBAAiB,CACzB,WAAW,CAAE,IAAI,CACjB,UAAU,CAAE,cAAc,CAE1B,qDAAQ,CACN,UAAU,CAAE,OAAO,CAEnB,yDAAI,CACF,IAAI,CAAE,IAAkB,CAMhC,sCAAmB,CACjB,IAAI,CAAE,CAAC,CAGT,+BAAc,CACZ,UAAU,CAAE,IAAI,CAEhB,6CAAc,CACZ,UAAU,CAAE,CAAC,CAGf,4CAAa,CACX,aAAa,CAAE,CAAC,CAIpB,+BAAc,CACZ,UAAU,CAAE,OAAO,CACnB,MAAM,CAAE,cAAc,CACtB,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,IAAI,CAGd,4GAAU,CACR,OAAO,CAAE,KAAK,CAGhB,mDAAE,CACA,MAAM,CAAE,CAAC,CAGX,4DAAW,CACT,WAAW,CAAE,IAAI,CAKvB,0BAAS,CACP,UAAU,CAAE,IAAI,CAGlB,8BAAa,CACX,UAAU,CAAE,cAAc,CAC1B,UAAU,CAAE,IAAI,CAChB,WAAW,CAAE,IAAI,CACjB,OAAO,CAAE,IAAI,CACb,qBAAqB,CAAE,OAAO,CAE9B,2CAAa,CACX,UAAU,CAAE,KAAK,CC9JvB,mBAAoB,CAClB,OAAO,CAAE,IAAI,CACb,qBAAqB,CAAE,OAAO,CAC9B,QAAQ,CAAE,IAAI,CACd,OAAO,CAAE,CAAC,CAEV,oCAAiB,CACf,OAAO,CAAE,KAAK,CAEd,wCAAI,CACF,aAAa,CAAE,IAAI,CAIvB,oCAAiB,CACf,MAAM,CAAE,CAAC,CCHb,mBAAoB,CAClB,cAAc,CAAE,MAAM,CAEtB,sDAAqC,CACnC,OAAO,CAAE,IAAI",
+"mappings": "AACE,2CAAqB,CACnB,OAAO,CAAE,CAAC,CACV,MAAM,CAAE,UAAU,CAElB,+CAAM,CACJ,MAAM,CAAE,WAAW,CAGrB,0DAAiB,CACf,MAAM,CAAE,SAAS,CAGnB,gDAAK,CACH,MAAM,CAAE,CAAC,CAKf,yBAA0B,CAEtB,+CAAM,CACJ,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,UAAU,CAGpB,0DAAiB,CACf,MAAM,CAAE,CAAC,CAGX,kDAAO,CACL,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CACX,SAAS,CAAE,IAAI,EC/BnB,sBAAY,CACV,aAAa,CAAE,IAAI,CAGrB,kBAAQ,CACN,MAAM,CAAE,IAAI,CACZ,QAAQ,CAAE,QAAQ,CAGpB,sBAAY,CACV,KAAK,CAAE,IAAI,CACX,eAAe,CAAE,KAAK,CACtB,mBAAmB,CAAE,MAAM,CAG7B,mBAAS,CACP,OAAO,CAAE,IAAI,CACb,WAAW,CAAE,MAAM,CAEnB,gCAAe,CACb,qBAAqB,CAAE,OAAO,CAIlC,yBAAe,CACb,UAAU,CAAE,MAAM,CAGpB,kBAAQ,CACN,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,CAAC,CAGZ,sBAAY,CACV,SAAS,CAAE,IAAI,CACf,OAAO,CAAE,GAAG,CAGd,wBAAc,CACZ,MAAM,CAAE,SAAS,CAGnB,sBAAY,CACV,MAAM,CAAE,OAAO,CAGjB,wBAAc,CACZ,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,OAAO,CAEf,0BAAE,CACA,MAAM,CAAE,UAAU,CAElB,qCAAa,CACX,MAAM,CAAE,CAAC,CAKf,kBAAQ,CACN,UAAU,CAAE,IAAI,CAGlB,mBAAS,CACP,UAAU,CAAE,IAAI,CAChB,WAAW,CAAE,IAAI,CACjB,UAAU,CAAE,cAAc,CAE1B,0CAAuB,CACrB,OAAO,CAAE,YAAY,CACrB,QAAQ,CAAE,QAAQ,CAElB,iEAAyB,CACvB,OAAO,CAAE,GAAG,CACZ,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CAMf,8BAAI,CACF,aAAa,CAAE,GAAG,CAClB,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,cAAc,CAAE,MAAM,CACtB,OAAO,CAAE,YAAY,CAGvB,4BAAI,CACF,eAAe,CAAE,IAAI,CACrB,UAAU,CAAE,IAAI,CAChB,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,YAAY,CAIzB,+CACY,CACV,cAAc,CAAE,MAAM,CAGxB,+BAAqB,CACnB,UAAU,CAAE,KAAK,CACjB,MAAM,CAAE,cAAc,CAGxB,iBAAO,CACL,OAAO,CAAE,IAAI,CAGf,mEAEW,CACT,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,OAAO,CAAE,GAAG,CACZ,MAAM,CAAE,iBAAiB,CACzB,aAAa,CAAE,GAAG,CAItB,yBAA0B,CAEtB,kBAAQ,CACN,OAAO,CAAE,IAAI,CACb,SAAS,CAAE,QAAQ,CAGrB,kBAAQ,CACN,IAAI,CAAE,KAAK,CAGb,sBAAY,CACV,MAAM,CAAE,IAAI,CAGd,iBAAO,CACL,IAAI,CAAE,CAAC,EAKb,yBAAyB,CACvB,sBAAuB,CACrB,WAAW,CAAE,MAAM,EClJrB,0BAAS,CACP,UAAU,CAAE,MAAM,CAGpB,wBAAO,CACL,MAAM,CAAE,eAAe,CAGzB,6BAAY,CACV,OAAO,CAAE,YAAY,CACrB,MAAM,CAAE,KAAK,CACb,SAAS,CAAE,IAAI,CACf,OAAO,CAAE,GAAG,CAGd,6BAAY,CACV,aAAa,CAAE,GAAG,CAGpB,yBAAQ,CACN,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,CAAC,CAGZ,6BAAU,CACR,MAAM,CAAE,IAAI,CAId,+BAAY,CACV,MAAM,CAAE,CAAC,CAIX,8CAA6B,CAC3B,KAAK,CAAE,IAAI,CACX,aAAa,CAAE,CAAC,CAChB,MAAM,CAAE,IAAI,CAGd,yBAAQ,CACN,UAAU,CAAE,MAAM,CAElB,6BAAM,CACJ,MAAM,CAAE,MAAM,CAIlB,yBAAQ,CACN,OAAO,CAAE,IAAI,CACb,eAAe,CAAE,MAAM,CAGzB,kCAAiB,CACf,OAAO,CAAE,IAAI,CACb,WAAW,CAAE,MAAM,CACnB,IAAI,CAAE,IAAI,CACV,UAAU,CAAE,KAAK,CACjB,OAAO,CAAE,SAAS,CAClB,UAAU,CAAE,IAAI,CAChB,eAAe,CAAE,IAAI,CACrB,OAAO,CAAE,IAAI,CAGX,mDAAI,CACF,IAAI,CAAE,OAAe,CAIzB,oDAAoB,CAClB,UAAU,CAAE,IAAI,CAChB,aAAa,CAAE,MAAM,CAErB,wDAAI,CACF,IAAI,CAAE,IAAkB,CAK5B,uDAAuB,CACrB,UAAU,CAAE,IAAI,CAEhB,6DAAQ,CACN,gBAAgB,CAAE,kBAAqB,CAGzC,2DAAI,CACF,IAAI,CAAE,IAAkB,CAI5B,+CAAe,CACb,MAAM,CAAE,iBAAiB,CACzB,WAAW,CAAE,IAAI,CACjB,UAAU,CAAE,cAAc,CAE1B,qDAAQ,CACN,UAAU,CAAE,OAAO,CAEnB,yDAAI,CACF,IAAI,CAAE,IAAkB,CAMhC,sCAAmB,CACjB,IAAI,CAAE,CAAC,CAGT,+BAAc,CACZ,UAAU,CAAE,IAAI,CAEhB,6CAAc,CACZ,UAAU,CAAE,CAAC,CAGf,4CAAa,CACX,aAAa,CAAE,CAAC,CAIpB,+BAAc,CACZ,UAAU,CAAE,OAAO,CACnB,MAAM,CAAE,cAAc,CACtB,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,IAAI,CAGd,4GAAU,CACR,OAAO,CAAE,KAAK,CAGhB,mDAAE,CACA,MAAM,CAAE,CAAC,CAGX,4DAAW,CACT,WAAW,CAAE,IAAI,CAKvB,0BAAS,CACP,UAAU,CAAE,IAAI,CAGlB,8BAAa,CACX,UAAU,CAAE,cAAc,CAC1B,UAAU,CAAE,IAAI,CAChB,WAAW,CAAE,IAAI,CACjB,OAAO,CAAE,IAAI,CACb,qBAAqB,CAAE,OAAO,CAE9B,2CAAa,CACX,UAAU,CAAE,KAAK,CC5JvB,mBAAoB,CAClB,OAAO,CAAE,IAAI,CACb,qBAAqB,CAAE,OAAO,CAC9B,QAAQ,CAAE,IAAI,CACd,OAAO,CAAE,CAAC,CAEV,oCAAiB,CACf,OAAO,CAAE,KAAK,CAEd,wCAAI,CACF,aAAa,CAAE,IAAI,CAIvB,oCAAiB,CACf,MAAM,CAAE,CAAC,CCHb,mBAAoB,CAClB,cAAc,CAAE,MAAM",
"sources": ["partials/_sorting.scss","partials/_archive.scss","partials/_single.scss","partials/_shortcodes.scss","sermon.scss"],
"names": [],
"file": "sermon.min.css"
diff --git a/assets/css/sermon.scss b/assets/css/sermon.scss
index d024d1b..0794499 100644
--- a/assets/css/sermon.scss
+++ b/assets/css/sermon.scss
@@ -12,8 +12,4 @@
*/
.wpfc-sermon-player {
vertical-align: middle;
-
- + .wpfc-sermon-single-audio-download {
- display: none;
- }
}
diff --git a/assets/css/theme-specific/Divi.css b/assets/css/theme-specific/Divi.css
new file mode 100644
index 0000000..fec873c
--- /dev/null
+++ b/assets/css/theme-specific/Divi.css
@@ -0,0 +1,3 @@
+article.wpfc_sermon {
+ margin-bottom: 50px;
+}
diff --git a/assets/css/theme-specific/twentyfourteen.css b/assets/css/theme-specific/twentyfourteen.css
index 74b74be..c92d151 100644
--- a/assets/css/theme-specific/twentyfourteen.css
+++ b/assets/css/theme-specific/twentyfourteen.css
@@ -17,6 +17,7 @@
margin-bottom: 48px;
}
+/*noinspection SpellCheckingInspection*/
.full-width .site-content .hentry.has-post-thumbnail:first-child {
margin-top: 0 !important;
}
\ No newline at end of file
diff --git a/assets/css/theme-specific/wpfc-morgan.css b/assets/css/theme-specific/wpfc-morgan.css
new file mode 100644
index 0000000..ded4290
--- /dev/null
+++ b/assets/css/theme-specific/wpfc-morgan.css
@@ -0,0 +1,3 @@
+.player-wordpress .wpfc-sermon-single-audio-download {
+ margin-bottom: 0;
+}
\ No newline at end of file
diff --git a/assets/js/additional_classes.js b/assets/js/additional_classes.js
deleted file mode 100644
index d13843b..0000000
--- a/assets/js/additional_classes.js
+++ /dev/null
@@ -1,9 +0,0 @@
-(function () {
- var element = document.getElementsByClassName('wpfc-sermon');
-
- for (var i = 0; i < element.length; i++) {
- if (element[i].offsetWidth > 600) {
- element[i].className += " wpfc-sermon-horizontal";
- }
- }
-})();
diff --git a/assets/js/admin/dismiss-php.js b/assets/js/admin/dismiss-php.js
index 858fa00..da76b40 100644
--- a/assets/js/admin/dismiss-php.js
+++ b/assets/js/admin/dismiss-php.js
@@ -1,3 +1,5 @@
+var ajaxurl = typeof ajaxurl !== 'undefined' ? ajaxurl : '';
+
// Modified from: https://wordpress.stackexchange.com/a/251191/111583
jQuery(function ($) {
$(document).on('click', '.notice-wpfc-php .notice-dismiss', function () {
@@ -9,4 +11,4 @@ jQuery(function ($) {
}
});
});
-});
\ No newline at end of file
+});
diff --git a/assets/js/admin/dismiss-php.min.js b/assets/js/admin/dismiss-php.min.js
new file mode 100644
index 0000000..3257cb0
--- /dev/null
+++ b/assets/js/admin/dismiss-php.min.js
@@ -0,0 +1 @@
+var ajaxurl=typeof ajaxurl!=="undefined"?ajaxurl:"";jQuery(function($){$(document).on("click",".notice-wpfc-php .notice-dismiss",function(){$.ajax(ajaxurl,{type:"POST",data:{action:"wpfc_php_notice_handler",type:$(this).closest(".notice-wpfc-php").data("notice")}})})});
\ No newline at end of file
diff --git a/assets/js/admin/import-export.js b/assets/js/admin/import-export.js
index ed92d2f..4d1da48 100644
--- a/assets/js/admin/import-export.js
+++ b/assets/js/admin/import-export.js
@@ -13,4 +13,4 @@ jQuery(document).ready(function () {
submitButton.click();
});
}
-});
\ No newline at end of file
+});
diff --git a/assets/js/admin/import-export.min.js b/assets/js/admin/import-export.min.js
new file mode 100644
index 0000000..6367b56
--- /dev/null
+++ b/assets/js/admin/import-export.min.js
@@ -0,0 +1 @@
+jQuery(document).ready(function(){var smImportForm=jQuery("#sm-import-upload-form");if(smImportForm.length){var fileField=smImportForm.find("#upload");var importTrigger=smImportForm.siblings("#sm-import-trigger");var submitButton=smImportForm.find("#submit");importTrigger.click(function(){fileField.click()});fileField.change(function(){importTrigger.find(".import-sniper").css("display","inline-block");importTrigger.attr("disabled",true);submitButton.click()})}});
\ No newline at end of file
diff --git a/assets/js/admin/settings.js b/assets/js/admin/settings.js
index f05dbc0..a7ba7c0 100644
--- a/assets/js/admin/settings.js
+++ b/assets/js/admin/settings.js
@@ -38,4 +38,4 @@ function podcast_redirect(show) {
show ? temp.show() : temp.hide();
}
-}
\ No newline at end of file
+}
diff --git a/assets/js/admin/settings.min.js b/assets/js/admin/settings.min.js
new file mode 100644
index 0000000..c112450
--- /dev/null
+++ b/assets/js/admin/settings.min.js
@@ -0,0 +1 @@
+jQuery("#enable_podcast_redirection").change(function(){podcast_redirect(this.checked)});jQuery(document).ready(function(){var check=jQuery("#enable_podcast_redirection");if(check.length){podcast_redirect(check.is(":checked"))}});function podcast_redirect(show){if(typeof show!=="boolean")return;var el=[jQuery("#podcast_redirection_old_url"),jQuery("#podcast_redirection_new_url")];for(var i=0;i [db-host] [wp-version] [skip-database-creation]"
+ exit 1
+fi
+
+DB_NAME=$1
+DB_USER=$2
+DB_PASS=$3
+DB_HOST=${4-localhost}
+WP_VERSION=${5-latest}
+SKIP_DB_CREATE=${6-false}
+
+TMPDIR=${TMPDIR-/tmp}
+TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
+WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
+WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
+
+download() {
+ if [ `which curl` ]; then
+ curl -s "$1" > "$2";
+ elif [ `which wget` ]; then
+ wget -nv -O "$2" "$1"
+ fi
+}
+
+if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
+ WP_TESTS_TAG="branches/$WP_VERSION"
+elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
+ if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
+ # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
+ WP_TESTS_TAG="tags/${WP_VERSION%??}"
+ else
+ WP_TESTS_TAG="tags/$WP_VERSION"
+ fi
+elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
+ WP_TESTS_TAG="trunk"
+else
+ # http serves a single offer, whereas https serves multiple. we only want one
+ download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
+ grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
+ LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
+ if [[ -z "$LATEST_VERSION" ]]; then
+ echo "Latest WordPress version could not be found"
+ exit 1
+ fi
+ WP_TESTS_TAG="tags/$LATEST_VERSION"
+fi
+
+set -ex
+
+install_wp() {
+
+ if [ -d $WP_CORE_DIR ]; then
+ return;
+ fi
+
+ mkdir -p $WP_CORE_DIR
+
+ if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
+ mkdir -p $TMPDIR/wordpress-nightly
+ download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip
+ unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
+ mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
+ else
+ if [ $WP_VERSION == 'latest' ]; then
+ local ARCHIVE_NAME='latest'
+ elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
+ # https serves multiple offers, whereas http serves single.
+ download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
+ if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
+ # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
+ LATEST_VERSION=${WP_VERSION%??}
+ else
+ # otherwise, scan the releases and get the most up to date minor version of the major release
+ local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
+ LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
+ fi
+ if [[ -z "$LATEST_VERSION" ]]; then
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
+ else
+ local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
+ fi
+ else
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
+ fi
+ download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
+ tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
+ fi
+
+ download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
+}
+
+install_test_suite() {
+ # portable in-place argument for both GNU sed and Mac OSX sed
+ if [[ $(uname -s) == 'Darwin' ]]; then
+ local ioption='-i .bak'
+ else
+ local ioption='-i'
+ fi
+
+ # set up testing suite if it doesn't yet exist
+ if [ ! -d $WP_TESTS_DIR ]; then
+ # set up testing suite
+ mkdir -p $WP_TESTS_DIR
+ svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
+ svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
+ fi
+
+ if [ ! -f wp-tests-config.php ]; then
+ download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
+ # remove all forward slashes in the end
+ WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
+ sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
+ fi
+
+}
+
+install_db() {
+
+ if [ ${SKIP_DB_CREATE} = "true" ]; then
+ return 0
+ fi
+
+ # parse DB_HOST for port or socket references
+ local PARTS=(${DB_HOST//\:/ })
+ local DB_HOSTNAME=${PARTS[0]};
+ local DB_SOCK_OR_PORT=${PARTS[1]};
+ local EXTRA=""
+
+ if ! [ -z $DB_HOSTNAME ] ; then
+ if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
+ EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
+ elif ! [ -z $DB_SOCK_OR_PORT ] ; then
+ EXTRA=" --socket=$DB_SOCK_OR_PORT"
+ elif ! [ -z $DB_HOSTNAME ] ; then
+ EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
+ fi
+ fi
+
+ # create database
+ mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
+}
+
+install_wp
+install_test_suite
+install_db
diff --git a/changelog.txt b/changelog.txt
index fa303e8..595bc28 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,6 @@
+### 2.12.5 ###
+* New: Added support for Beaver Builder
+
### 2.11.3 ###
* Fix: Sermon date not being saved when date format is changed
* Fix: YouTube short URL was not being detected (thanks @macbookandrew)
diff --git a/includes/admin-functions.php b/includes/admin-functions.php
deleted file mode 100644
index 7e2e584..0000000
--- a/includes/admin-functions.php
+++ /dev/null
@@ -1,287 +0,0 @@
-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 = '';
-
- if ( current_user_can( 'edit_posts' ) ) {
- $count .= '' . $text . ' ';
- } else {
- $count .= $text;
- }
-
- $count .= ' ';
- $count .= "";
- echo $count;
-}
-
-
-/*
-Taxonomy Short Description
-http://wordpress.mfields.org/plugins/taxonomy-short-description/
-Shortens the description shown in the administration panels for all categories, tags and custom taxonomies.
-V: 1.3.1
-Copyright 2011 Michael Fields michael@mfields.org
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 2 as published by
-the Free Software Foundation.
-
-Function names have been modified to prevent conflicts.
-*/
-
-// Actions.
-function wpfc_taxonomy_short_description_actions() {
- $taxonomies = get_taxonomies();
- foreach ( $taxonomies as $taxonomy ) {
- $config = get_taxonomy( $taxonomy );
- if ( isset( $config->show_ui ) && true == $config->show_ui ) {
- add_action( 'manage_' . $taxonomy . '_custom_column', 'wpfc_taxonomy_short_description_rows', 10, 3 );
- add_action( 'manage_edit-' . $taxonomy . '_columns', 'wpfc_taxonomy_short_description_columns' );
- add_filter( 'manage_edit-' . $taxonomy . '_sortable_columns', 'wpfc_taxonomy_short_description_columns' );
- }
- }
-}
-
-// Term Columns.
-// Remove the default "Description" column. Add a custom "Short Description" column.
-function wpfc_taxonomy_short_description_columns( $columns ) {
- $position = 0;
- $iterator = 1;
- foreach ( $columns as $column => $display_name ) {
- if ( 'name' == $column ) {
- $position = $iterator;
- }
- $iterator ++;
- }
- if ( 0 < $position ) {
- /* Store all columns up to and including "Name". */
- $before = $columns;
- array_splice( $before, $position );
-
- /* All of the other columns are stored in $after. */
- $after = $columns;
- $after = array_diff( $columns, $before );
-
- /* Prepend a custom column for the short description. */
- $after = array_reverse( $after, true );
- $after['mfields_short_description'] = $after['description'];
- $after = array_reverse( $after, true );
-
- /* Remove the original description column. */
- unset( $after['description'] );
-
- /* Join all columns back together. */
- $columns = $before + $after;
- }
-
- return $columns;
-}
-
-
-// Term Rows. - Display the shortened description in each row's custom column.
-function wpfc_taxonomy_short_description_rows( $string, $column_name, $term ) {
- if ( 'mfields_short_description' == $column_name ) {
- global $taxonomy;
- $string = term_description( $term, $taxonomy );
- $string = wpfc_taxonomy_short_description_shorten( $string, apply_filters( 'mfields_taxonomy_short_description_length', 130 ) );
- }
-
- return $string;
-}
-
-// Shorten a string to a given length.
-function wpfc_taxonomy_short_description_shorten( $string, $max_length = 23, $append = '…', $encoding = 'utf8' ) {
-
- /* Sanitize $string. */
- $string = strip_tags( $string );
- $string = trim( $string );
- $string = html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );
- $string = rtrim( $string, '-' );
-
- /* Sanitize $max_length */
- if ( 0 == abs( (int) $max_length ) ) {
- $max_length = 23;
- }
-
- /* Return early if the php "mbstring" extension is not installed. */
- if ( ! function_exists( 'mb_substr' ) ) {
- $length = strlen( $string );
- if ( $length > $max_length ) {
- return substr_replace( $string, $append, $max_length );
- }
-
- return $string;
- }
-
- /* Count how many characters are in the string. */
- $length = strlen( utf8_decode( $string ) );
-
- /* String is longer than max-length. It needs to be shortened. */
- if ( $length > $max_length ) {
-
- /* Shorten the string to max-length */
- $short = substr( $string, 0, $max_length );
-
- /*
- * A word has been cut in half during shortening.
- * If the shortened string contains more than one word
- * the last word in the string will be removed.
- */
- if ( 0 !== strpos( $string, $short . ' ', 0 ) ) {
- $pos = strpos( $short, ' ' );
- if ( false !== $pos ) {
- $short = strpos( $short, 0, $pos );
- }
- }
-
- /* Append shortened string with the value of $append preceeded by a non-breaking space. */
- $string = $short . ' ' . $append;
- }
-
- return $string;
-}
-
-/**
- * Returns duration of an MP3 file
- *
- * @param string $mp3_url URL to the MP3 file
- *
- * @return string duration
- */
-function wpfc_mp3_duration( $mp3_url ) {
- if ( empty( $mp3_url ) ) {
- return '';
- }
-
- if ( ! class_exists( 'getID3' ) ) {
- require_once ABSPATH . 'wp-includes/ID3/getid3.php';
- }
-
- // create a temporary file for the MP3 file
- $filename = tempnam( '/tmp', 'getid3' );
-
- if ( file_put_contents( $filename, file_get_contents( $mp3_url ) ) ) {
- $getID3 = new getID3;
- $ThisFileInfo = $getID3->analyze( $filename );
- unlink( $filename );
- }
-
- $duration = isset( $ThisFileInfo['playtime_string'] ) ? $ThisFileInfo['playtime_string'] : '';
-
- return $duration;
-}
diff --git a/includes/admin/class-sm-admin-assets.php b/includes/admin/class-sm-admin-assets.php
index 864fe67..708be0c 100644
--- a/includes/admin/class-sm-admin-assets.php
+++ b/includes/admin/class-sm-admin-assets.php
@@ -1,10 +1,19 @@
id : '';
- // Register admin styles
+ // Register admin styles.
wp_register_style( 'sm_admin_styles', SM_URL . 'assets/css/admin.min.css', array(), SM_VERSION );
- // Enqueue styles for Sermon Manager pages only
+ // Enqueue styles for Sermon Manager pages only.
if ( in_array( $screen_id, sm_get_screen_ids() ) ) {
wp_enqueue_style( 'sm_admin_styles' );
+
+ do_action( 'sm_enqueue_admin_css' );
}
}
@@ -33,9 +44,9 @@ public function admin_scripts() {
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
- // Enqueue scripts for Sermon Manager pages only
+ // 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
+ do_action( 'sm_enqueue_admin_js' );
}
}
}
diff --git a/includes/admin/class-sm-admin-import-export.php b/includes/admin/class-sm-admin-import-export.php
index 74a550c..8076446 100644
--- a/includes/admin/class-sm-admin-import-export.php
+++ b/includes/admin/class-sm-admin-import-export.php
@@ -1,4 +1,10 @@
All Sermons).
+ add_action( 'admin_menu', array( $this, 'fix_sermons_title' ), 100 );
}
/**
- * Add menu item
+ * Add menu item.
*/
public function settings_menu() {
- add_submenu_page( 'edit.php?post_type=wpfc_sermon', __( 'Sermon Manager Settings', 'sermon-manager-for-wordpress' ), __( 'Settings', 'sermon-manager-for-wordpress' ), 'manage_options', 'sm-settings', array(
+ add_submenu_page( 'edit.php?post_type=wpfc_sermon', __( 'Sermon Manager Settings', 'sermon-manager-for-wordpress' ), __( 'Settings', 'sermon-manager-for-wordpress' ), 'manage_wpfc_sm_settings', 'sm-settings', array(
$this,
- 'settings_page'
+ 'settings_page',
) );
}
@@ -29,33 +40,51 @@ public function settings_menu() {
* Add menu item.
*/
public function import_export_menu() {
- add_submenu_page( 'edit.php?post_type=wpfc_sermon', __( 'Sermon Manager Import/Export', 'sermon-manager-for-wordpress' ), __( 'Import/Export', 'sermon-manager-for-wordpress' ), 'manage_options', 'sm-import-export', array(
+ add_submenu_page( 'edit.php?post_type=wpfc_sermon', __( 'Sermon Manager Import/Export', 'sermon-manager-for-wordpress' ), __( 'Import/Export', 'sermon-manager-for-wordpress' ), 'manage_wpfc_sm_settings', 'sm-import-export', array(
$this,
- 'import_export_page'
+ 'import_export_page',
) );
}
/**
- * Init the settings page
+ * Init the settings page.
*/
public function settings_page() {
SM_Admin_Settings::output();
}
/**
- * Init the settings page
+ * Init the settings page.
*/
public function import_export_page() {
- wp_enqueue_script( 'import-export-js', SM_URL . 'assets/js/admin/import-export.js', array(), SM_VERSION );
+ wp_enqueue_script( 'import-export-js', SM_URL . 'assets/js/admin/import-export' . ( ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) ? '' : '.min' ) . '.js', array(), SM_VERSION );
SM_Admin_Import_Export::output();
}
/**
- * Fixes Sermon Manager top-level icon
+ * Fixes Sermon Manager top-level icon.
*/
public function fix_icon() {
wp_enqueue_style( 'sm-icon', SM_URL . 'assets/css/admin-icon.css', array(), SM_VERSION );
}
+
+ /**
+ * Changes child menu item name to All Sermons.
+ */
+ public function fix_sermons_title() {
+ global $submenu;
+
+ if ( ! isset( $submenu['edit.php?post_type=wpfc_sermon'] ) ) {
+ return;
+ }
+
+ foreach ( $submenu['edit.php?post_type=wpfc_sermon'] as &$sermon_item ) {
+ if ( 'edit.php?post_type=wpfc_sermon' === $sermon_item[2] ) {
+ $sermon_item[0] = __( 'All Sermons', 'sermon-manager-for-wordpress' );
+ return;
+ }
+ }
+ }
}
return new SM_Admin_Menus();
diff --git a/includes/admin/class-sm-admin-post-types.php b/includes/admin/class-sm-admin-post-types.php
index 17d2381..6526794 100644
--- a/includes/admin/class-sm-admin-post-types.php
+++ b/includes/admin/class-sm-admin-post-types.php
@@ -1,4 +1,10 @@
'', // Unused. Messages start at index 1.
+ // translators: %s: The URL to the sermon.
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 */
+ // 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,
+ // translators: %s: The URL to the sermon.
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' ),
+ // translators: %s: The URL to the sermon.
8 => wp_sprintf( esc_html__( 'Sermon submitted. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . ' ' ),
+ // translators: %1$s: The date and time. %2$s: The preview sermon URL.
9 => wp_sprintf( esc_html__( 'Sermon scheduled for: %1$s. %2$s', 'sermon-manager-for-wordpress' ),
+ // translators: %1$s: Date. %2$s: Time.
'' . 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' ) . ' ' ),
+ // translators: %s: The preview sermon URL.
+ '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . ' '
+ ),
+ // translators: %s The URL to the sermon.
10 => wp_sprintf( esc_html__( 'Sermon draft updated. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . ' ' ),
);
@@ -64,7 +82,7 @@ public function post_updated_messages( $messages ) {
/**
* Define custom columns for sermons.
*
- * @param array $existing_columns
+ * @param array $existing_columns Existing columns.
*
* @return array
*/
@@ -91,7 +109,7 @@ public function sermon_columns( $existing_columns ) {
/**
* Output custom columns for sermons.
*
- * @param string $column
+ * @param string $column The column to render.
*/
public function render_sermon_columns( $column ) {
global $post;
@@ -101,19 +119,19 @@ public function render_sermon_columns( $column ) {
}
switch ( $column ) {
- case "preacher":
+ case 'preacher':
$data = get_the_term_list( $post->ID, 'wpfc_preacher', '', ', ', '' );
break;
- case "series":
+ case 'series':
$data = get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' );
break;
- case "topics":
+ case 'topics':
$data = get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' );
break;
- case "views":
+ case 'views':
$data = wpfc_entry_views_get( array( 'post_id' => $post->ID ) );
break;
- case "preached":
+ case 'preached':
/**
* Modified from code in wp-admin/includes/class-wp-posts-list-table.php
*/
@@ -122,7 +140,8 @@ public function render_sermon_columns( $column ) {
$data = '';
if ( '0000-00-00 00:00:00' === $post->post_date ) {
- $t_time = $h_time = __( 'Unpublished' );
+ $t_time = __( 'Unpublished' );
+ $h_time = __( 'Unpublished' );
$time_diff = 0;
} else {
$t_time = sm_get_the_date( __( 'Y/m/d g:i:s a' ) );
@@ -132,6 +151,7 @@ public function render_sermon_columns( $column ) {
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
+ // translators: %s: The time. Such as "12 hours".
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
} else {
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
@@ -177,7 +197,7 @@ public function render_sermon_columns( $column ) {
}
break;
- default :
+ default:
$data = '';
break;
}
@@ -192,7 +212,7 @@ public function render_sermon_columns( $column ) {
/**
* Make columns sortable
*
- * @param array $columns
+ * @param array $columns The existing columns.
*
* @return array
*/
@@ -210,8 +230,8 @@ public function sermon_sortable_columns( $columns ) {
* Set list table primary column
* Support for WordPress 4.3.
*
- * @param string $default
- * @param string $screen_id
+ * @param string $default Existing primary column.
+ * @param string $screen_id Current screen ID.
*
* @return string
*/
@@ -226,8 +246,8 @@ public function list_table_primary_column( $default, $screen_id ) {
/**
* Set row actions for sermons
*
- * @param array $actions
- * @param WP_Post $post
+ * @param array $actions The existing actions.
+ * @param WP_Post $post Sermon or other post instance.
*
* @return array
*/
@@ -242,7 +262,7 @@ public function row_actions( $actions, $post ) {
/**
* Filters and sorting handler.
*
- * @param array $vars
+ * @param array $vars Current filtering arguments.
*
* @return array
*/
@@ -250,7 +270,7 @@ public function request_query( $vars ) {
global $typenow;
if ( 'wpfc_sermon' === $typenow ) {
- // Sorting
+ // Sorting.
if ( isset( $vars['orderby'] ) ) {
switch ( $vars['orderby'] ) {
case 'preached':
@@ -282,13 +302,13 @@ public function request_query( $vars ) {
/**
* Change title boxes in admin.
*
- * @param string $text
- * @param object $post
+ * @param string $text The title.
+ * @param object $post The post.
*
* @return string
*/
public function enter_title_here( $text, $post ) {
- if ( $post->post_type === 'wpfc_sermon' ) {
+ if ( 'wpfc_sermon' === $post->post_type ) {
$text = __( 'Sermon title', 'sermon-manager-for-wordpress' );
}
@@ -298,7 +318,7 @@ public function enter_title_here( $text, $post ) {
/**
* Filter the sermons in admin based on options
*
- * @param mixed $query
+ * @param mixed $query The query.
*/
public function sermon_filters_query( $query ) {
global $typenow;
@@ -309,7 +329,7 @@ public function sermon_filters_query( $query ) {
array(
'taxonomy' => 'wpfc_service_type',
'field' => 'slug',
- 'terms' => $query->query_vars['wpfc_service_type']
+ 'terms' => $query->query_vars['wpfc_service_type'],
)
);
}
@@ -333,9 +353,11 @@ public function restrict_manage_posts() {
public function sermon_filters() {
global $wp_query;
- // Type filtering
+ // Type filtering.
$terms = get_terms( 'wpfc_service_type' );
- $output = '';
+ $output = '';
+
+ $output .= '';
$output .= '' . __( 'Filter by Service Type', 'sermon-manager-for-wordpress' ) . ' ';
foreach ( $terms as $term ) {
@@ -358,4 +380,4 @@ public function sermon_filters() {
}
}
-new SM_Admin_Post_Types();
\ No newline at end of file
+new SM_Admin_Post_Types();
diff --git a/includes/admin/class-sm-admin-settings.php b/includes/admin/class-sm-admin-settings.php
index 9c57041..02909d6 100644
--- a/includes/admin/class-sm-admin-settings.php
+++ b/includes/admin/class-sm-admin-settings.php
@@ -1,4 +1,10 @@
__( 'The changes you made will be lost if you navigate away from this page.', 'sermon-manager-for-wordpress' ),
'i18n_bible_spanish_note' => __( 'Note: WordPress is not set to any Spanish variant. Reverted to ESV.', 'sermon-manager-for-wordpress' ),
- 'is_wp_spanish' => strpos( get_locale(), 'es_' ) !== false
+ 'is_wp_spanish' => strpos( get_locale(), 'es_' ) !== false,
) );
- // Include settings pages
+ // Include settings pages.
self::get_settings_pages();
- // Get current tab/section
+ // 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
+ // Save settings if data has been posted.
if ( ! empty( $_POST ) ) {
self::save();
}
- // Add any posted messages
+ // Add any posted messages.
if ( ! empty( $_GET['sm_error'] ) ) {
self::add_error( stripslashes( $_GET['sm_error'] ) );
}
@@ -81,7 +99,7 @@ public static function output() {
switch ( $current_tab ) {
case 'podcast':
- wp_enqueue_script( 'sm_settings_podcast' ); // todo: i18n the script & make it more dynamic
+ wp_enqueue_script( 'sm_settings_podcast' ); // todo: i18n the script & make it more dynamic.
wp_enqueue_media();
break;
case 'verse':
@@ -89,8 +107,8 @@ public static function output() {
break;
}
- // Get tabs for the settings page
- /** @noinspection PhpUnusedLocalVariableInspection */
+ // Get tabs for the settings page.
+ /* @noinspection PhpUnusedLocalVariableInspection */
$tabs = apply_filters( 'sm_settings_tabs_array', array() );
include 'views/html-admin-settings.php';
@@ -108,6 +126,7 @@ public static function get_settings_pages() {
$settings[] = include 'settings/class-sm-settings-general.php';
$settings[] = include 'settings/class-sm-settings-verse.php';
$settings[] = include 'settings/class-sm-settings-podcast.php';
+ $settings[] = include 'settings/class-sm-settings-import.php';
$settings[] = include 'settings/class-sm-settings-debug.php';
self::$settings = apply_filters( 'sm_get_settings_pages', $settings );
@@ -126,20 +145,20 @@ public static function save() {
die( __( 'Action failed. Please refresh the page and retry.', 'sermon-manager-for-wordpress' ) );
}
- // Trigger actions
+ // 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
+ // Clear any unwanted data and flush rules.
wp_schedule_single_event( time(), 'sm_flush_rewrite_rules' );
/**
- * Pass any false value to `sm_clear_feed_transients` filter to skip clearing transients
+ * Pass any false value to `sm_clear_feed_transients` filter to skip clearing transients.
*/
- if ( $current_tab === 'podcast' && apply_filters( 'sm_clear_feed_transients', true ) ) {
+ if ( 'podcast' === $current_tab && apply_filters( 'sm_clear_feed_transients', true ) ) {
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_feed_%') OR `option_name` LIKE ('_transient_timeout_feed_%')" );
}
@@ -149,7 +168,7 @@ public static function save() {
/**
* Add a message.
*
- * @param string $text
+ * @param string $text The message to add.
*/
public static function add_message( $text ) {
self::$messages[] = $text;
@@ -158,7 +177,7 @@ public static function add_message( $text ) {
/**
* Add an error.
*
- * @param string $text
+ * @param string $text The error to add.
*/
public static function add_error( $text ) {
self::$errors[] = $text;
@@ -169,7 +188,7 @@ public static function add_error( $text ) {
*
* Loops though the Sermon Manager options array and outputs each field.
*
- * @param array[] $options Opens array to output
+ * @param array[] $options Opens array to output.
*/
public static function output_fields( $options ) {
foreach ( $options as $value ) {
@@ -201,7 +220,7 @@ public static function output_fields( $options ) {
$value['placeholder'] = '';
}
- // Custom attribute handling
+ // Custom attribute handling.
$custom_attributes = array();
if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
@@ -210,16 +229,14 @@ public static function output_fields( $options ) {
}
}
- // Description handling
- // Reset variables
- $tooltip_html = $description = '';
- // Get descriptions
- $field_description = self::get_field_description( $value );
- extract( $field_description );
+ // Get descriptions.
+ $field_description = self::get_field_description( $value );
+ $description = $field_description['description'];
+ $tooltip_html = $field_description['tooltip_html'];
- // Switch based on type
+ // Switch based on type.
switch ( $value['type'] ) {
- // Section Titles
+ // Section Titles.
case 'title':
if ( ! empty( $value['title'] ) ) {
echo '' . esc_html( $value['title'] ) . ' ';
@@ -233,7 +250,7 @@ public static function output_fields( $options ) {
}
break;
- // Section Ends
+ // Section Ends.
case 'sectionend':
if ( ! empty( $value['id'] ) ) {
do_action( 'sm_settings_' . sanitize_title( $value['id'] ) . '_end' );
@@ -244,11 +261,11 @@ public static function output_fields( $options ) {
}
break;
- // Standard text inputs and subtypes like 'number'
+ // Standard text inputs and subtypes like 'number'.
case 'text':
case 'email':
case 'number':
- case 'password' :
+ case 'password':
if ( substr( $value['id'], 0, 2 ) === '__' && strlen( $value['id'] ) > 2 ) {
$option_value = $value['value'];
} else {
@@ -256,165 +273,170 @@ public static function output_fields( $options ) {
}
?>
-
-
-
-
-
-
-
-
- />
-
-
+
+
+
+
+
+
+ />
+
+
+
-
-
-
-
-
-
-
-
-
- />
-
-
-
+
+
+
+
+
+
+
+ />
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- >
- $val ) {
- ?>
-
+
+
+
+
+
+
+
+ >
+ $val ) {
+ ?>
+ >
-
-
-
-
+ >
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+ "
$visbility_class[] = 'show_options_if_checked';
}
?>
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
+
- />
-
-
-
-
+ />
+
+
+
+
" . __( '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
-
-
- id="-crop" type="checkbox"
- value="1" />
-
-
-
- $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 );
- }
-
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- />
-
-
-
-
+
+
+
+
+
+
+
+ />
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+ 'wpfc_sermon',
- 'author' => false,
- 'category' => false,
- 'start_date' => false,
- 'end_date' => false,
- 'status' => false,
- );
- $args = wp_parse_args($args, $defaults);
-
- /**
- * Fires at the beginning of an export, before any headers are sent.
- *
- * @since 2.3.0
- *
- * @param array $args An array of export arguments.
- */
- //do_action( 'export_wp', $args );
-
- $sitename = sanitize_key(get_bloginfo('name'));
- if (!empty($sitename)) $sitename .= '.';
- $filename = $sitename . 'wordpress.' . date('Y-m-d') . '.xml';
-
- header('Content-Description: File Transfer');
- header('Content-Disposition: attachment; filename=' . $filename);
- header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
-
- if ( post_type_exists($args['content']) ) {
- $ptype = get_post_type_object($args['content']);
- if (!$ptype->can_export)
- return;
-
- $where = $wpdb->prepare("{$wpdb->posts}.post_type = %s", $args['content']);
- } else {
- return;
- }
-
- $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
-
-
- $join = '';
-
- // grab a snapshot of post IDs, just in case it changes during the export
- $post_ids = apply_filters('export_post_ids', $wpdb->get_col("SELECT ID FROM {$wpdb->posts} $join WHERE $where"), $args);
- $post_type_export = apply_filters('export_post_type', 'wpfc_sermon', $args);
-
- // get the requested terms ready, empty unless posts filtered by category or all content
- $cats = $tags = $terms = array();
- $custom_taxonomies = array(
- 'wpfc_preacher',
- 'wpfc_sermon_series',
- 'wpfc_sermon_topics',
- 'wpfc_bible_book',
- 'wpfc_service_type'
- );
- $custom_terms = (array)get_terms($custom_taxonomies, array('get' => 'all'));
-
- // put terms in order with no child going before its parent
- while ($t = array_shift($custom_terms)) {
- if ($t->parent == 0 || isset($terms[$t->parent]))
- $terms[$t->term_id] = $t;
- else
- $custom_terms[] = $t;
- }
-
- unset($categories, $custom_taxonomies, $custom_terms);
-
- /**
- * Wrap given string in XML CDATA tag.
- *
- * @since 2.1.0
- *
- * @param string $str String to wrap in XML CDATA tag.
- * @return string
- */
- function wxr_cdata($str)
- {
- if (seems_utf8($str) == false)
- $str = utf8_encode($str);
-
- // $str = ent2ncr(esc_html($str));
- $str = '', ']]]]>', $str) . ']]>';
-
- return $str;
- }
-
- /**
- * Return the URL of the site
- *
- * @since 2.5.0
- *
- * @return string Site URL.
- */
- function wxr_site_url()
- {
- // ms: the base url
- if (is_multisite())
- return network_home_url();
- // wp: the blog url
- else
- return get_bloginfo_rss('url');
- }
-
- /**
- * Output list of taxonomy terms, in XML tag format, associated with a post
- *
- * @since 2.3.0
- */
- function wxr_post_taxonomy($post_id) {
- $custom_taxonomies = array(
- 'wpfc_preacher',
- 'wpfc_sermon_series',
- 'wpfc_sermon_topics',
- 'wpfc_bible_book',
- 'wpfc_service_type'
- );
- $terms = wp_get_object_terms( $post_id, $custom_taxonomies );
-
- foreach ( (array) $terms as $term ) {
- echo "\t\ttaxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . " \n";
- }
- }
-
- /**
- * Output a cat_name XML tag from a given category object
- *
- * @since 2.1.0
- *
- * @param object $category Category Object
- */
- function wxr_cat_name($category)
- {
- if (empty($category->name))
- return;
-
- echo '' . wxr_cdata($category->name) . ' ';
- }
-
- /**
- * Output a category_description XML tag from a given category object
- *
- * @since 2.1.0
- *
- * @param object $category Category Object
- */
- function wxr_category_description($category)
- {
- if (empty($category->description))
- return;
-
- echo '' . wxr_cdata($category->description) . ' ';
- }
-
- /**
- * Output a tag_name XML tag from a given tag object
- *
- * @since 2.3.0
- *
- * @param object $tag Tag Object
- */
- function wxr_tag_name($tag)
- {
- if (empty($tag->name))
- return;
-
- echo '' . wxr_cdata($tag->name) . ' ';
- }
-
- /**
- * Output a tag_description XML tag from a given tag object
- *
- * @since 2.3.0
- *
- * @param object $tag Tag Object
- */
- function wxr_tag_description($tag)
- {
- if (empty($tag->description))
- return;
-
- echo '' . wxr_cdata($tag->description) . ' ';
- }
-
- /**
- * Output a term_name XML tag from a given term object
- *
- * @since 2.9.0
- *
- * @param object $term Term Object
- */
- function wxr_term_name($term)
- {
- if (empty($term->name))
- return;
-
- echo '' . wxr_cdata($term->name) . ' ';
- }
-
- /**
- * Output a term_description XML tag from a given term object
- *
- * @since 2.9.0
- *
- * @param object $term Term Object
- */
- function wxr_term_description($term)
- {
- if (empty($term->description))
- return;
-
- echo '' . wxr_cdata($term->description) . ' ';
- }
-
- /**
- * Output list of authors with posts
- *
- * @since 3.1.0
- */
- function wxr_authors_list()
- {
- global $wpdb;
-
- $authors = array();
- $results = $wpdb->get_results("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft'");
- foreach ((array)$results as $result)
- $authors[] = get_userdata($result->post_author);
-
- $authors = array_filter($authors);
-
- foreach ($authors as $author) {
- echo "\t";
- echo '' . $author->ID . ' ';
- echo '' . $author->user_login . ' ';
- echo '' . $author->user_email . ' ';
- echo '' . wxr_cdata($author->display_name) . ' ';
- echo '' . wxr_cdata($author->user_firstname) . ' ';
- echo '' . wxr_cdata($author->user_lastname) . ' ';
- echo " \n";
- }
- }
-
- function wxr_filter_postmeta($return_me, $meta_key)
- {
- if ('_edit_lock' == $meta_key)
- $return_me = true;
- return $return_me;
- }
-
- add_filter('wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2);
-
- function sermon_return_attachment_id_from_url( $attachment_url ) {
- global $wpdb;
- $attachment_id = '';
-
- //is attachment url set?
- if ( $attachment_url !== '' ) {
- //prepare query
-
- $query = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid=%s", $attachment_url );
-
- //get attachment id
- $attachment_id = $wpdb->get_var( $query );
- }
-
- //return id
- return $attachment_id;
- }
-
- echo '\n";
-
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- term_id ?>
- taxonomy; ?>
- slug; ?>
- parent ? $terms[$t->parent]->slug : ''; ?>
-
-
- get_results($wpdb->prepare("SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $t->term_id));
- foreach ($termmeta as $meta) :
- /**
- * Filter whether to selectively skip post meta used for WXR exports.
- *
- * Returning a truthy value to the filter will skip the current meta
- * object from being exported.
- *
- * @since 3.3.0
- *
- * @param bool $skip Whether to skip the current post meta. Default false.
- * @param string $meta_key Current meta key.
- * @param object $meta Current meta object.
- */
- if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta))
- continue;
- ?>
-
- meta_key; ?>
- meta_value); ?>
-
-
- term_id, $assigned_term_images) ) { ?>
-
- sm_term_image_id
- term_id]; ?>
-
-
-
-
-
-
-
- in_the_loop = true; // Fake being in the loop.
-
- /* NEW CODE START */
- $meta_value_array = array();
- $meta_key_name = array(
- 'sermon_audio',
- 'sermon_video',
- 'sermon_video_link',
- 'sermon_notes',
- 'sermon_bulletin'
- );
- foreach ($post_ids as $post) {
- $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post));
- $postobject = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post));
- $meta_value = array();
- if ($postobject[0]->post_type == $post_type_export) {
- foreach ($postmeta as $meta) {
- if ($meta->meta_key == '_thumbnail_id') {
- $meta_value[] = $meta->meta_value;
- }
- if (in_array($meta->meta_key, $meta_key_name)) {
- $attachment_id_temp = sermon_return_attachment_id_from_url($meta->meta_value);
- if( !empty($attachment_id_temp) ) {
- $meta_value[] = $attachment_id_temp;
- }
- }
- }
- }
- if (isset($meta_value) && is_array($meta_value)) {
- $meta_value_array = array_unique(array_merge($meta_value_array, $meta_value), SORT_REGULAR);
- }
- }
- $attachment_array = array();
- foreach ($assigned_term_images as $term => $attachment) {
- $attachment_array[] = $attachment;
- }
- $attachment_array = array_unique($attachment_array, SORT_REGULAR);
- $post_ids = array_merge($post_ids, $meta_value_array, $attachment_array);
- /* NEW CODE END */
-
- // fetch 20 posts at a time rather than loading the entire table into memory
- while ($next_posts = array_splice($post_ids, 0, 20)) {
- $where = 'WHERE ID IN (' . join(',', $next_posts) . ')';
- $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} $where");
-
- // Begin Loop
- foreach ($posts as $post) {
- setup_postdata($post);
- $is_sticky = is_sticky($post->ID) ? 1 : 0;
- ?>
- -
-
-
post_title); ?>
-
-
-
-
-
- post_content));
- ?>
- post_excerpt));
- ?>
- ID; ?>
- post_date; ?>
- post_date_gmt; ?>
- comment_status; ?>
- ping_status; ?>
- post_name; ?>
- post_status; ?>
- post_parent; ?>
- menu_order; ?>
- post_type; ?>
- post_password; ?>
-
- ID); ?>
- post_type == 'attachment') : ?>
- ID); ?>
-
- get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID));
- foreach ($postmeta as $meta) :
- /**
- * Filter whether to selectively skip post meta used for WXR exports.
- *
- * Returning a truthy value to the filter will skip the current meta
- * object from being exported.
- *
- * @since 3.3.0
- *
- * @param bool $skip Whether to skip the current post meta. Default false.
- * @param string $meta_key Current meta key.
- * @param object $meta Current meta object.
- */
- if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta))
- continue;
- ?>
-
- meta_key; ?>
- meta_value); ?>
-
-
- get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID));
- foreach ($comments as $c) : ?>
-
- comment_ID; ?>
- comment_author); ?>
- comment_author_email; ?>
- comment_author_url); ?>
- comment_author_IP; ?>
- comment_date; ?>
- comment_date_gmt; ?>
- comment_content) ?>
- comment_approved; ?>
- comment_type; ?>
- comment_parent; ?>
- user_id; ?>
- get_results($wpdb->prepare("SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID));
- foreach ($c_meta as $meta) : ?>
-
- meta_key; ?>
- meta_value); ?>
-
-
-
-
-
-
-
-
- 'wpfc_sermon',
+ 'author' => false,
+ 'category' => false,
+ 'start_date' => false,
+ 'end_date' => false,
+ 'status' => false,
+ );
+ $args = wp_parse_args( $args, $defaults );
+
+ $sitename = sanitize_key( get_bloginfo( 'name' ) );
+ if ( ! empty( $sitename ) ) {
+ $sitename .= '.';
+ }
+ $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml';
+
+ header( 'Content-Description: File Transfer' );
+ header( 'Content-Disposition: attachment; filename=' . $filename );
+ header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
+
+ if ( post_type_exists( $args['content'] ) ) {
+ $ptype = get_post_type_object( $args['content'] );
+ if ( ! $ptype->can_export ) {
+ return;
+ }
+
+ $where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] );
+ } else {
+ return;
+ }
+
+ $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
+
+ $join = '';
+
+ // Grab a snapshot of post IDs, just in case it changes during the export.
+ $post_ids = apply_filters( 'export_post_ids', $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" ), $args );
+ $post_type_export = apply_filters( 'export_post_type', 'wpfc_sermon', $args );
+
+ // Get the requested terms ready, empty unless posts filtered by category or all content.
+ $cats = array();
+ $tags = array();
+ $terms = array();
+ $custom_taxonomies = array(
+ 'wpfc_preacher',
+ 'wpfc_sermon_series',
+ 'wpfc_sermon_topics',
+ 'wpfc_bible_book',
+ 'wpfc_service_type',
+ );
+ $custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
+
+ // put terms in order with no child going before its parent.
+ while ( $t = array_shift( $custom_terms ) ) {
+ if ( 0 == $t->parent || isset( $terms[ $t->parent ] ) ) {
+ $terms[ $t->term_id ] = $t;
+ } else {
+ $custom_terms[] = $t;
+ }
+ }
+
+ unset( $categories, $custom_taxonomies, $custom_terms );
+
+ /**
+ * Wrap given string in XML CDATA tag.
+ *
+ * @since 2.1.0
+ *
+ * @param string $str String to wrap in XML CDATA tag.
+ *
+ * @return string
+ */
+ function wxr_cdata( $str ) {
+ if ( seems_utf8( $str ) == false ) {
+ $str = utf8_encode( $str );
+ }
+
+ $str = '', ']]]]>', $str ) . ']]>';
+
+ return $str;
+ }
+
+ /**
+ * Return the URL of the site
+ *
+ * @since 2.5.0
+ *
+ * @return string Site URL.
+ */
+ function wxr_site_url() {
+ // ms: the base url.
+ if ( is_multisite() ) {
+ return network_home_url();
+ } // wp: the blog url.
+ else {
+ return get_bloginfo_rss( 'url' );
+ }
+ }
+
+ /**
+ * Output list of taxonomy terms, in XML tag format, associated with a post
+ *
+ * @since 2.3.0
+ *
+ * @param int $post_id The post ID.
+ */
+ function wxr_post_taxonomy( $post_id ) {
+ $custom_taxonomies = array(
+ 'wpfc_preacher',
+ 'wpfc_sermon_series',
+ 'wpfc_sermon_topics',
+ 'wpfc_bible_book',
+ 'wpfc_service_type',
+ );
+ $terms = wp_get_object_terms( $post_id, $custom_taxonomies );
+
+ foreach ( (array) $terms as $term ) {
+ echo "\t\ttaxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . " \n";
+ }
+ }
+
+ /**
+ * Output a cat_name XML tag from a given category object
+ *
+ * @since 2.1.0
+ *
+ * @param object $category Category Object.
+ */
+ function wxr_cat_name( $category ) {
+ if ( empty( $category->name ) ) {
+ return;
+ }
+
+ echo '' . wxr_cdata( $category->name ) . ' ';
+ }
+
+ /**
+ * Output a category_description XML tag from a given category object
+ *
+ * @since 2.1.0
+ *
+ * @param object $category Category Object.
+ */
+ function wxr_category_description( $category ) {
+ if ( empty( $category->description ) ) {
+ return;
+ }
+
+ echo '' . wxr_cdata( $category->description ) . ' ';
+ }
+
+ /**
+ * Output a tag_name XML tag from a given tag object
+ *
+ * @since 2.3.0
+ *
+ * @param object $tag Tag Object.
+ */
+ function wxr_tag_name( $tag ) {
+ if ( empty( $tag->name ) ) {
+ return;
+ }
+
+ echo '' . wxr_cdata( $tag->name ) . ' ';
+ }
+
+ /**
+ * Output a tag_description XML tag from a given tag object
+ *
+ * @since 2.3.0
+ *
+ * @param object $tag Tag Object.
+ */
+ function wxr_tag_description( $tag ) {
+ if ( empty( $tag->description ) ) {
+ return;
+ }
+
+ echo '' . wxr_cdata( $tag->description ) . ' ';
+ }
+
+ /**
+ * Output a term_name XML tag from a given term object
+ *
+ * @since 2.9.0
+ *
+ * @param object $term Term Object.
+ */
+ function wxr_term_name( $term ) {
+ if ( empty( $term->name ) ) {
+ return;
+ }
+
+ echo '' . wxr_cdata( $term->name ) . ' ';
+ }
+
+ /**
+ * Output a term_description XML tag from a given term object
+ *
+ * @since 2.9.0
+ *
+ * @param object $term Term Object.
+ */
+ function wxr_term_description( $term ) {
+ if ( empty( $term->description ) ) {
+ return;
+ }
+
+ echo '' . wxr_cdata( $term->description ) . ' ';
+ }
+
+ /**
+ * Output list of authors with posts
+ *
+ * @since 3.1.0
+ */
+ function wxr_authors_list() {
+ global $wpdb;
+
+ $authors = array();
+ $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft'" );
+ foreach ( (array) $results as $result ) {
+ $authors[] = get_userdata( $result->post_author );
+ }
+
+ $authors = array_filter( $authors );
+
+ foreach ( $authors as $author ) {
+ echo "\t";
+ echo '' . $author->ID . ' ';
+ echo '' . $author->user_login . ' ';
+ echo '' . $author->user_email . ' ';
+ echo '' . wxr_cdata( $author->display_name ) . ' ';
+ echo '' . wxr_cdata( $author->user_firstname ) . ' ';
+ echo '' . wxr_cdata( $author->user_lastname ) . ' ';
+ echo " \n";
+ }
+ }
+
+ /**
+ * Filters post meta fields.
+ *
+ * @param mixed $return_me Meta value.
+ * @param string $meta_key Meta key.
+ *
+ * @return mixed
+ */
+ function wxr_filter_postmeta( $return_me, $meta_key ) {
+ if ( '_edit_lock' == $meta_key ) {
+ $return_me = true;
+ }
+
+ return $return_me;
+ }
+
+ add_filter( 'wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2 );
+
+ /**
+ * Find the attachment ID.
+ *
+ * @param string $attachment_url The URL.
+ *
+ * @return null|string
+ */
+ function sermon_return_attachment_id_from_url( $attachment_url ) {
+ global $wpdb;
+ $attachment_id = '';
+
+ // is attachment url set?
+ if ( '' !== $attachment_url ) {
+ // prepare query.
+ $query = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid=%s", $attachment_url );
+
+ // get attachment id.
+ $attachment_id = $wpdb->get_var( $query );
+ }
+
+ // return id.
+ return $attachment_id;
+ }
+
+ echo '\n";
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ term_id; ?>
+ taxonomy; ?>
+ slug; ?>
+ parent ? $terms[ $t->parent ]->slug : ''; ?>
+
+
+ get_results( $wpdb->prepare( "SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $t->term_id ) );
+ foreach ( $termmeta as $meta ) :
+ /**
+ * Filter whether to selectively skip post meta used for WXR exports.
+ *
+ * Returning a truthy value to the filter will skip the current meta
+ * object from being exported.
+ *
+ * @since 3.3.0
+ *
+ * @param bool $skip Whether to skip the current post meta. Default false.
+ * @param string $meta_key Current meta key.
+ * @param object $meta Current meta object.
+ */
+ if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
+ continue;
+ }
+ ?>
+
+ meta_key; ?>
+ meta_value ); ?>
+
+
+ term_id, $assigned_term_images ) ) { ?>
+
+ sm_term_image_id
+ term_id ]; ?>
+
+
+
+
+
+
+
+ in_the_loop = true; // Fake being in the loop.
+
+ /* NEW CODE START */
+ $meta_value_array = array();
+ $meta_key_name = array(
+ 'sermon_audio',
+ 'sermon_video',
+ 'sermon_video_link',
+ 'sermon_notes',
+ 'sermon_bulletin',
+ );
+ foreach ( $post_ids as $post ) {
+ $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post ) );
+ $postobject = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post ) );
+ $meta_value = array();
+ if ( $postobject[0]->post_type == $post_type_export ) {
+ foreach ( $postmeta as $meta ) {
+ if ( '_thumbnail_id' == $meta->meta_key ) {
+ $meta_value[] = $meta->meta_value;
+ }
+ if ( in_array( $meta->meta_key, $meta_key_name ) ) {
+ $attachment_id_temp = sermon_return_attachment_id_from_url( $meta->meta_value );
+ if ( ! empty( $attachment_id_temp ) ) {
+ $meta_value[] = $attachment_id_temp;
+ }
+ }
+ }
+ }
+ if ( isset( $meta_value ) && is_array( $meta_value ) ) {
+ $meta_value_array = array_unique( array_merge( $meta_value_array, $meta_value ), SORT_REGULAR );
+ }
+ }
+ $attachment_array = array();
+ foreach ( $assigned_term_images as $term => $attachment ) {
+ $attachment_array[] = $attachment;
+ }
+ $attachment_array = array_unique( $attachment_array, SORT_REGULAR );
+ $post_ids = array_merge( $post_ids, $meta_value_array, $attachment_array );
+ /* NEW CODE END */
+
+ // fetch 20 posts at a time rather than loading the entire table into memory.
+ while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) {
+ $where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
+ $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
+
+ // Begin Loop.
+ foreach ( $posts as $post ) {
+ setup_postdata( $post );
+ $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
+ ?>
+ -
+
+
post_title ); ?>
+
+
+
+
+
+
+ post_content ) );
+ ?>
+
+
+ post_excerpt ) );
+ ?>
+
+ ID; ?>
+ post_date; ?>
+ post_date_gmt; ?>
+ comment_status; ?>
+ ping_status; ?>
+ post_name; ?>
+ post_status; ?>
+ post_parent; ?>
+ menu_order; ?>
+ post_type; ?>
+ post_password; ?>
+
+ ID ); ?>
+ post_type ) : ?>
+ ID ); ?>
+
+ get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
+ foreach ( $postmeta as $meta ) :
+ /**
+ * Filter whether to selectively skip post meta used for WXR exports.
+ *
+ * Returning a truthy value to the filter will skip the current meta
+ * object from being exported.
+ *
+ * @since 3.3.0
+ *
+ * @param bool $skip Whether to skip the current post meta. Default false.
+ * @param string $meta_key Current meta key.
+ * @param object $meta Current meta object.
+ */
+ if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
+ continue;
+ }
+ ?>
+
+ meta_key; ?>
+ meta_value ); ?>
+
+
+ get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
+ foreach ( $comments as $c ) :
+ ?>
+
+ comment_ID; ?>
+ comment_author ); ?>
+ comment_author_email; ?>
+ comment_author_url ); ?>
+ comment_author_IP; ?>
+ comment_date; ?>
+ comment_date_gmt; ?>
+ comment_content ); ?>
+ comment_approved; ?>
+ comment_type; ?>
+ comment_parent; ?>
+ user_id; ?>
+ get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
+ foreach ( $c_meta as $meta ) :
+ ?>
+
+ meta_key; ?>
+ meta_value ); ?>
+
+
+
+
+
+
+
+
+ is_debug = ! ! \SermonManager::getOption( 'debug_import' );
$this->start_time = microtime( true );
@@ -40,12 +82,15 @@ public static function is_installed() {
return $wpdb->query( "SELECT id FROM {$wpdb->prefix}sb_sermons LIMIT 1 " ) !== false;
}
+ /**
+ * Update latest importing log.
+ */
public function __destruct() {
update_option( 'sm_last_import_info', $this->debug_data );
}
/**
- * Do the import
+ * Do the import.
*/
public function import() {
$this->log( 'Init info:' . PHP_EOL . 'Sermon Manager ' . SM_VERSION . PHP_EOL . 'Release Date: ' . date( 'Y-m-d', filemtime( SM_PLUGIN_FILE ) ), 255 );
@@ -85,11 +130,11 @@ public function import() {
}
/**
- * Logs a message to show in debug
+ * Logs a message to show in debug.
*
- * @param string $message
- * @param int $severity
- * @param bool $no_time To hide time or not
+ * @param string $message The message.
+ * @param int $severity Message severity.
+ * @param bool $no_time To hide time or not.
*
* @since 2.11.0
*/
@@ -127,13 +172,14 @@ public function log( $message = '', $severity = 254, $no_time = false ) {
}
/**
- * Imports Bible Books
+ * 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 = term_exists( $book->book_name, 'wpfc_bible_book' );
+ if ( $term_data ) {
$this->log( 'Term "' . $book->book_name . '" already exists. (ID: ' . $term_data['term_id'] . ')' );
} else {
$term_data = wp_insert_term( $book->book_name, 'wpfc_bible_book' );
@@ -152,7 +198,7 @@ private function _import_books() {
}
/**
- * Gets the names of all Bible Books that were used in Sermon Browser
+ * Gets the names of all Bible Books that were used in Sermon Browser.
*
* @return array
*/
@@ -173,32 +219,33 @@ private function _get_used_books() {
}
/**
- * Allows to filter books that will be imported
+ * Allows to filter books that will be imported.
*
- * @var array $used_books list of book names 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
+ * Imports Preachers.
*/
private function _import_preachers() {
global $wpdb;
/**
- * Filter preachers that will be imported
+ * 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 = term_exists( $preacher->name, 'wpfc_preacher' );
+ if ( $term_data ) {
$this->log( 'Term "' . $preacher->name . '" already exists. (ID: ' . $term_data['term_id'] . ')' );
} else {
$term_data = wp_insert_term( $preacher->name, 'wpfc_preacher', array(
- 'desc' => apply_filters( 'sm_import_sb_preacher_description', $preacher->description ?: '' )
+ 'desc' => apply_filters( 'sm_import_sb_preacher_description', $preacher->description ?: '' ),
) );
if ( ! $term_data instanceof WP_Error ) {
$this->log( 'Term "' . $preacher->name . '" imported. (ID: ' . $term_data['term_id'] . ')' );
@@ -208,8 +255,8 @@ private function _import_preachers() {
}
}
- if ( $preacher->image !== '' ) {
- // Set image
+ 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 ) ) {
@@ -226,13 +273,13 @@ private function _import_preachers() {
}
/**
- * Imports Series
+ * Imports Series.
*/
private function _import_series() {
global $wpdb;
/**
- * Filter series that will be imported
+ * Filter series that will be imported.
*
* @var array Raw database data
*/
@@ -243,7 +290,8 @@ private function _import_series() {
continue;
}
- if ( $term_data = term_exists( $item->name, 'wpfc_sermon_series' ) ) {
+ $term_data = term_exists( $item->name, 'wpfc_sermon_series' );
+ if ( $term_data ) {
$this->log( 'Term "' . $item->name . '" already exists. (ID: ' . $term_data['term_id'] . ')' );
} else {
$term_data = wp_insert_term( $item->name, 'wpfc_sermon_series' );
@@ -262,23 +310,24 @@ private function _import_series() {
}
/**
- * Imports Service Types
+ * Imports Service Types.
*/
private function _import_service_types() {
global $wpdb;
/**
- * Filter service types that will be imported
+ * Filter service types that will be imported.
*
- * @var array Raw database data
+ * @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 = term_exists( $service->name, 'wpfc_service_type' );
+ if ( $term_data ) {
$this->log( 'Term "' . $service->name . '" already exists. (ID: ' . $term_data['term_id'] . ')' );
} else {
- $term_data = wp_insert_term( $service->name, 'wpfc_sermon_series' );
+ $term_data = wp_insert_term( $service->name, 'wpfc_service_type' );
if ( ! $term_data instanceof WP_Error ) {
$this->log( 'Term "' . $service->name . '" imported. (ID: ' . $term_data['term_id'] . ')' );
} else {
@@ -294,7 +343,7 @@ private function _import_service_types() {
}
/**
- * Sermon tags are not working in SB, so we can't know how to import them
+ * Sermon tags are not working in SB, so we can't know how to import them.
*/
private function _import_sermon_tags() {
$this->log( 'Not implemented.', 2 );
@@ -303,15 +352,15 @@ private function _import_sermon_tags() {
}
/**
- * Imports Sermons
+ * Imports Sermons.
*/
private function _import_sermons() {
global $wpdb;
- // Imported sermons
+ // Imported sermons.
$imported = get_option( '_sm_import_sb_messages', array() );
- // SB options
+ // SB options.
$options = get_option( 'sermonbrowser_options', array(
'upload_dir' => 'wp-content/uploads/sermons/',
) );
@@ -323,9 +372,9 @@ private function _import_sermons() {
$this->log( 'Sermon Browser plugin options: Show data ' . ob_get_clean() . '
', 0 );
/**
- * Filter sermons that will be imported
+ * Filter sermons that will be imported.
*
- * @var array $sermons Raw database data
+ * @var array $sermons Raw database data.
*/
$sermons = apply_filters( 'sm_import_sb_messages', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_sermons" ) );
@@ -334,19 +383,19 @@ private function _import_sermons() {
$this->log( 'Raw sermon data: Show data ' . ob_get_clean() . '
', 0 );
-
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',
+ 'post_date' => $sermon->datetime,
+ 'post_content' => '%todo_render%',
+ 'post_title' => $sermon->title,
+ 'post_type' => 'wpfc_sermon',
+ 'post_status' => 'publish',
+ 'comment_status' => SermonManager::getOption( 'import_disallow_comments' ) ? 'closed' : 'open',
) ) );
- if ( $id === 0 || $id instanceof WP_Error ) {
- // skip if error
+ if ( 0 === $id || $id instanceof WP_Error ) {
+ // Skip if error.
$this->log( 'Sermon "' . $sermon->title . '" could not be imported. (error data: ' . serialize( $id ) . ')', 2 );
continue;
} else {
@@ -354,7 +403,7 @@ private function _import_sermons() {
}
$imported[ $sermon->id ] = array(
- 'new_id' => $id
+ 'new_id' => $id,
);
/**
@@ -368,21 +417,21 @@ private function _import_sermons() {
}
/**
- * Filter stuff that will be imported
+ * Filter stuff that will be imported.
*
- * @var array $stuff Raw database data
+ * @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}'" ) );
+ $stuff = apply_filters( 'sm_import_sb_message_stuff', $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}sb_stuff WHERE `sermon_id` = %d", $sermon->id ) ) );
ob_start();
print_r( $stuff );
$this->log( 'Raw files data: Show data ' . ob_get_clean() . '
', 253 );
- // set files
+ // Set files.
update_post_meta( $id, 'sm_files', $stuff );
- // set mp3
+ // Set mp3.
foreach ( $stuff as $item ) {
$url = $item->name;
@@ -398,35 +447,35 @@ private function _import_sermons() {
}
}
- // set speaker
+ // Set speaker.
wp_set_object_terms( $id, intval( $this->_imported_preachers[ intval( $sermon->preacher_id ) ]['new_id'] ), 'wpfc_preacher' );
$this->log( 'Assigned preacher with ID ' . intval( $this->_imported_preachers[ intval( $sermon->preacher_id ) ]['new_id'] ), 253 );
- // set service type
+ // Set service type.
wp_set_object_terms( $id, intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ), 'wpfc_service_type' );
$this->log( 'Assigned service type with ID ' . intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ), 253 );
- // set series
+ // Set series.
wp_set_object_terms( $id, intval( $this->_imported_series[ intval( $sermon->series_id ) ]['new_id'] ), 'wpfc_sermon_series' );
$this->log( 'Assigned series with ID ' . intval( $this->_imported_series[ intval( $sermon->series_id ) ]['new_id'] ), 253 );
- // set description
+ // Set description.
update_post_meta( $id, 'sermon_description', $sermon->description );
- // set passage
+ // Set passage.
update_post_meta( $id, 'bible_passages_start', $sermon->start );
update_post_meta( $id, 'bible_passages_end', $sermon->end );
- // set date
+ // Set date.
update_post_meta( $id, 'sermon_date', strtotime( $sermon->datetime ) );
$this->log( 'Set sermon_date to ' . date( 'c', strtotime( $sermon->datetime ) ), 253 );
- update_post_meta( $id, 'sermon_date_auto', '1' );
+ update_post_meta( $id, 'sermon_date_auto', SermonManager::getOption( 'import_disable_auto_dates' ) ? '0' : '1' );
- // set views
- update_post_meta( $id, 'Views', $wpdb->get_var( "SELECT SUM(`count`) FROM {$wpdb->prefix}sb_stuff WHERE `sermon_id` = '{$sermon->id}'" ) );
+ // Set views.
+ update_post_meta( $id, 'Views', $wpdb->get_var( $wpdb->prepare( "SELECT SUM(`count`) FROM {$wpdb->prefix}sb_stuff WHERE `sermon_id` = %d", $sermon->id ) ) );
}
- // update term counts
+ // Update term counts.
foreach (
array(
'_imported_preachers' => 'wpfc_preacher',
@@ -448,4 +497,4 @@ private function _import_sermons() {
_update_generic_term_count( $terms, (object) array( 'name' => $taxonomy ) );
}
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/import/class-sm-import-se.php b/includes/admin/import/class-sm-import-se.php
index cd795bf..f7ebdec 100644
--- a/includes/admin/import/class-sm-import-se.php
+++ b/includes/admin/import/class-sm-import-se.php
@@ -1,4 +1,10 @@
_get_used_books();
foreach ( $used_books as $book ) {
- if ( ! $term_data = term_exists( $book->book_name, 'wpfc_bible_book' ) ) {
+ $term_data = term_exists( $book->book_name, 'wpfc_bible_book' );
+ if ( ! $term_data ) {
$term_data = wp_insert_term( $book->book_name, 'wpfc_bible_book' );
}
@@ -71,7 +94,7 @@ private function _import_books() {
}
/**
- * Gets the names of all Bible Books that were used in Series Engine
+ * Gets the names of all Bible Books that were used in Series Engine.
*
* @return array
*/
@@ -88,23 +111,23 @@ private function _get_used_books() {
}
/**
- * Filter books that will be imported
+ * Filter books that will be imported.
*
- * @var array $books list of book data 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
+ * Imports Speakers.
*/
private function _import_speakers() {
global $wpdb;
/**
- * Filter speakers that will be imported
+ * Filter speakers that will be imported.
*
- * @var array $speakers Raw database data
+ * @var array $speakers Raw database data.
*/
$speakers = apply_filters( 'sm_import_se_speakers', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}se_speakers" ) );
@@ -113,10 +136,11 @@ private function _import_speakers() {
array(
$speaker->first_name,
$speaker->last_name,
- $speaker->first_name . ' ' . $speaker->last_name
+ $speaker->first_name . ' ' . $speaker->last_name,
) as $name
) {
- if ( $term_data = term_exists( $name, 'wpfc_preacher' ) ) {
+ $term_data = term_exists( $name, 'wpfc_preacher' );
+ if ( $term_data ) {
break;
}
}
@@ -134,27 +158,28 @@ private function _import_speakers() {
}
/**
- * Imports Series
+ * Imports Series.
*/
private function _import_series() {
global $wpdb;
/**
- * Filter series that will be imported
+ * Filter series that will be imported.
*
- * @var array $series Raw database data
+ * @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 = term_exists( $item->s_title, 'wpfc_sermon_series' );
+ if ( ! $term_data ) {
$term_data = wp_insert_term( $item->s_title, 'wpfc_sermon_series', array(
- 'description' => apply_filters( 'sm_import_se_series_description', $item->s_description ?: '' )
+ 'description' => apply_filters( 'sm_import_se_series_description', $item->s_description ?: '' ),
) );
}
if ( ! $term_data instanceof WP_Error ) {
- // Set image
+ // 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' );
@@ -170,20 +195,21 @@ private function _import_series() {
}
/**
- * Imports Topics
+ * Imports Topics.
*/
private function _import_topics() {
global $wpdb;
/**
- * Filter topics that will be imported
+ * Filter topics that will be imported.
*
- * @var array $topics Raw database data
+ * @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 = term_exists( $topic->name, 'wpfc_sermon_topics' );
+ if ( ! $term_data ) {
$term_data = wp_insert_term( $topic->name, 'wpfc_sermon_topics' );
}
@@ -196,67 +222,68 @@ private function _import_topics() {
}
/**
- * Import messages
+ * Import messages.
*/
private function _import_messages() {
global $wpdb;
- // Imported messages
+ // Imported messages.
$imported = get_option( '_sm_import_se_messages', array() );
/**
- * Filter messages that will be imported
+ * Filter messages that will be imported.
*
- * @var array Raw database data
+ * @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
+ * Filter speaker association table that will be imported.
*
- * @var array Raw database data
+ * @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
+ * Filter topics association table that will be imported.
*
- * @var array Raw database data
+ * @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
+ * Filter books association table that will be imported.
*
- * @var array Raw database data
+ * @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
+ * Filter series association table that will be imported.
*
- * @var array Raw database data
+ * @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
+ // Start the import.
foreach ( $messages as $message ) {
$post_id = $message->wp_post_id;
$the_post = null;
- if ( $post_id !== null ) {
+ if ( null !== $post_id ) {
$the_post = get_post( $message->wp_post_id );
} else {
$post_id = $message->message_id;
}
if ( ! isset( $imported[ $post_id ] ) ) {
- if ( $the_post === null ) {
+ if ( null === $the_post ) {
$id = wp_insert_post( apply_filters( 'sm_import_se_message', array(
- 'post_date' => $message->date . ' 12:00:00',
- 'post_content' => '%todo_render%',
- 'post_title' => $message->title,
- 'post_type' => 'wpfc_sermon',
- 'post_status' => 'publish',
+ 'post_date' => $message->date . ' 12:00:00',
+ 'post_content' => '%todo_render%',
+ 'post_title' => $message->title,
+ 'post_type' => 'wpfc_sermon',
+ 'post_status' => 'publish',
+ 'comment_status' => SermonManager::getOption( 'import_disallow_comments' ) ? 'closed' : 'open',
) ) );
} else {
$id = wp_insert_post( apply_filters( 'sm_import_se_message', array(
@@ -269,31 +296,33 @@ private function _import_messages() {
'post_type' => 'wpfc_sermon',
'post_modified' => $the_post->post_modified,
'post_modified_gmt' => $the_post->post_modified_gmt,
+ 'comment_status' => SermonManager::getOption( 'import_disallow_comments' ) ? 'closed' : 'open',
) ) );
}
- if ( $id === 0 || $id instanceof WP_Error) {
- // silently skip if error
+ if ( 0 === $id || $id instanceof WP_Error ) {
+ // Silently skip if error.
continue;
}
$imported[ $post_id ] = array(
- 'new_id' => $id
+ '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
+ * 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[ $post_id ]['new_id'];
}
- // set speakers
- if ( $keys = array_keys( array_map( function ( $element ) {
+ // Set speakers.
+ $keys = array_keys( array_map( function ( $element ) {
return $element->message_id;
- }, $messages_speakers ), $message->message_id ) ) {
+ }, $messages_speakers ), $message->message_id );
+ if ( $keys ) {
$terms = array();
foreach ( $keys as $key ) {
$terms[] = intval( $this->_imported_speakers[ intval( $messages_speakers[ $key ]->speaker_id ) ]['new_id'] );
@@ -304,10 +333,11 @@ private function _import_messages() {
}
}
- // set books
- if ( $keys = array_keys( array_map( function ( $element ) {
+ // Set books.
+ $keys = array_keys( array_map( function ( $element ) {
return $element->message_id;
- }, $messages_books ), $message->message_id ) ) {
+ }, $messages_books ), $message->message_id );
+ if ( $keys ) {
$terms = array();
foreach ( $keys as $key ) {
$terms[] = intval( $this->_imported_books[ intval( $messages_books[ $key ]->book_id ) ]['new_id'] );
@@ -318,10 +348,11 @@ private function _import_messages() {
}
}
- // set topics
- if ( $keys = array_keys( array_keys( array_map( function ( $element ) {
+ // Set topics.
+ $keys = array_keys( array_keys( array_map( function ( $element ) {
return $element->message_id;
- }, $messages_topics ), $message->message_id ) ) ) {
+ }, $messages_topics ), $message->message_id ) );
+ if ( $keys ) {
$terms = array();
foreach ( $keys as $key ) {
$terms[] = intval( $this->_imported_topics[ intval( $messages_topics[ $key ]->topic_id ) ]['new_id'] );
@@ -332,10 +363,11 @@ private function _import_messages() {
}
}
- // set series
- if ( $keys = array_keys( array_map( function ( $element ) {
+ // Set series.
+ $keys = array_keys( array_map( function ( $element ) {
return $element->message_id;
- }, $messages_series ), $message->message_id ) ) {
+ }, $messages_series ), $message->message_id );
+ if ( $keys ) {
$terms = array();
foreach ( $keys as $key ) {
$terms[] = intval( $this->_imported_series[ intval( $messages_series[ $key ]->series_id ) ]['new_id'] );
@@ -346,69 +378,69 @@ private function _import_messages() {
}
}
- // set scripture
+ // Set scripture.
if ( ! empty( $message->focus_scripture ) ) {
update_post_meta( $id, 'bible_passage', $message->focus_scripture );
}
- // set description
+ // 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' ) {
+ // Set sermon date.
+ if ( ! empty( $message->date ) && '0000-00-00' !== $message->date ) {
update_post_meta( $id, 'sermon_date', strtotime( $message->date ) );
} else {
- if ( $the_post !== null ) {
+ if ( null !== $the_post ) {
update_post_meta( $id, 'sermon_date', strtotime( $the_post->post_date ) );
} else {
update_post_meta( $id, 'sermon_date', strtotime( $message->date ) );
}
- update_post_meta( $id, 'sermon_date_auto', '1' );
+ update_post_meta( $id, 'sermon_date_auto', SermonManager::getOption( 'import_disable_auto_dates' ) ? '0' : '1' );
}
- // set audio length
+ // 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)
+ // Set audio size (bytes).
if ( ! empty( $message->audio_file_size ) ) {
update_post_meta( $id, '_wpfc_sermon_size', $message->audio_file_size );
}
- // set audio file
+ // Set audio file.
if ( ! empty( $message->audio_url ) ) {
update_post_meta( $id, 'sermon_audio', $message->audio_url );
}
- // set video url
+ // Set video url.
if ( ! empty( $message->video_url ) ) {
update_post_meta( $id, 'sermon_video_link', $message->video_url );
}
- // set video embed
+ // Set video embed.
if ( ! empty( $message->embed_code ) ) {
update_post_meta( $id, 'sermon_video', $message->embed_code );
}
- // set views
+ // Set views.
if ( ! empty( $message->audio_count ) ) {
update_post_meta( $id, 'Views', $message->audio_count );
}
- // Update main file
+ // Update main file.
if ( ! empty( $message->file_url ) ) {
update_post_meta( $id, 'sermon_notes', $message->file_url );
}
- // Set image
+ // Set image.
sm_import_and_set_post_thumbnail( $message->message_thumbnail, $id );
}
- // update term counts
+ // Update term counts.
foreach (
array(
'_imported_speakers' => 'wpfc_preacher',
@@ -419,9 +451,7 @@ private function _import_messages() {
) {
$terms = array();
- if ( empty( $this->{
- $terms_array
- } ) ) {
+ if ( empty( $this->{$terms_array} ) ) {
continue;
}
diff --git a/includes/admin/import/class-sm-import-sm.php b/includes/admin/import/class-sm-import-sm.php
index 1347d94..5189da7 100644
--- a/includes/admin/import/class-sm-import-sm.php
+++ b/includes/admin/import/class-sm-import-sm.php
@@ -1,114 +1,315 @@
is_debug = ! ! \SermonManager::getOption( 'debug_import' );
+ $this->start_time = microtime( true );
}
-
+
/**
* Decide if the given meta key maps to information we will want to import
*
- * @param string $key The meta key to check
+ * @param string $key The meta key to check.
+ *
* @return string|bool The key if we do want to import, false if not
*/
function is_valid_meta_key( $key ) {
// skip attachment metadata since we'll regenerate it from scratch
- // skip _edit_lock as not relevant for import
- if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ) ) )
+ // skip _edit_lock as not relevant for import.
+ if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ) ) ) {
return false;
+ }
+
return $key;
}
-
+
/**
* Added to http_request_timeout filter to force timeout at 60 seconds during import
+ *
+ * @param int $val Default timeout.
+ *
* @return int 60
*/
function bump_request_timeout( $val ) {
return 60;
}
-
- public function __construct() {
- $this->is_debug = ! ! \SermonManager::getOption( 'debug_import' );
- $this->start_time = microtime( true );
- }
-
+
+ /**
+ * Update latest importing log.
+ */
public function __destruct() {
update_option( 'sm_last_import_info', $this->debug_data );
}
-
+
+ /**
+ * Do the import
+ */
+ public function import() {
+ $this->log( 'Init info:' . PHP_EOL . 'Sermon Manager ' . SM_VERSION . PHP_EOL . 'Release Date: ' . date( 'Y-m-d', filemtime( SM_PLUGIN_FILE ) ), 255 );
+ if ( ! doing_action( 'admin_init' ) ) {
+ $this->log( 'Scheduling for `admin_init` action.', 0 );
+ add_action( 'admin_init', array( $this, __FUNCTION__ ) );
+
+ return;
+ }
+
+ $this->log( 'Including import files.', 0 );
+ require_once( ABSPATH . 'wp-admin/includes/import.php' );
+
+ if ( ! class_exists( 'WP_Importer' ) ) {
+ $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
+ if ( file_exists( $class_wp_importer ) ) {
+ /* @noinspection PhpIncludeInspection */
+ require $class_wp_importer;
+ }
+ }
+ $this->log( 'Files included.', 0 );
+
+ add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) );
+ add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
+
+ $this->log( 'Doing `sm_import_before_sm` action.', 0 );
+ do_action( 'sm_import_before_sm' );
+ $this->log( 'Done.', 0 );
+
+ $this->log( 'Handling uploaded file.', 0 );
+ $upload = $this->handle_upload();
+ if ( $upload['status'] ) {
+ $this->log( 'File successfully loaded.', 0 );
+ $this->log( 'Starting content import.', 0 );
+ $this->importContent( $upload['file'] );
+ $this->log( 'Content import ended.', 0 );
+ } else {
+ /* Notify about failed file upload */
+ $this->log( 'Error while loading export file', 0 );
+ }
+
+ $this->log( 'Doing `sm_import_after_sm` action.', 0 );
+ do_action( 'sm_import_after_sm' );
+ $this->log( 'Done.', 0 );
+ }
+
/**
* Logs a message to show in debug
*
- * @param string $message
- * @param int $severity
- * @param bool $no_time To hide time or not
+ * @param string $message The message.
+ * @param int $severity The severity.
+ * @param bool $no_time To hide time or not.
*
* @since 2.11.0
*/
@@ -144,68 +345,22 @@ public function log( $message = '', $severity = 254, $no_time = false ) {
$this->debug_data .= $line . ' ' . $message . PHP_EOL;
}
-
- /**
- * Do the import
- */
- public function import() {
- $this->log( 'Init info:' . PHP_EOL . 'Sermon Manager ' . SM_VERSION . PHP_EOL . 'Release Date: ' . date( 'Y-m-d', filemtime( SM_PLUGIN_FILE ) ), 255 );
- if ( ! doing_action( 'admin_init' ) ) {
- $this->log( 'Scheduling for `admin_init` action.', 0 );
- add_action( 'admin_init', array( $this, __FUNCTION__ ) );
-
- return;
- }
-
- $this->log( 'Including import files.', 0 );
- require_once( ABSPATH . 'wp-admin/includes/import.php' );
-
- if ( ! class_exists( 'WP_Importer' ) ) {
- $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
- if ( file_exists( $class_wp_importer ) )
- require $class_wp_importer;
- }
- $this->log( 'Files included.', 0 );
-
- add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) );
- add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
-
- $this->log( 'Doing `sm_import_before_sm` action.', 0 );
- do_action( 'sm_import_before_sm' );
- $this->log( 'Done.', 0 );
-
- $this->log( 'Handling uploaded file.', 0 );
- $upload = $this->handle_upload();
- if($upload['status']) {
- $this->log( 'File successfully loaded.', 0 );
- $this->log( 'Starting content import.', 0 );
- $this->importContent( $upload['file'] );
- $this->log( 'Content import ended.', 0 );
- } else {
- /* Notify about failed file upload */
- $this->log( 'Error while loading export file', 0 );
- }
- $this->log( 'Doing `sm_import_after_sm` action.', 0 );
- do_action( 'sm_import_after_sm' );
- $this->log( 'Done.', 0 );
- }
-
- /**
+ /**
* Handles the WXR upload and initial parsing of the file to prepare for
* displaying author import options
*
- * @return bool False if error uploading or invalid file, true otherwise
+ * @return array ['status'] false if error uploading or invalid file, true otherwise
*/
function handle_upload() {
- $file = wp_import_handle_upload();
- $response = array();
+ $file = wp_import_handle_upload();
+ $response = array();
if ( isset( $file['error'] ) ) {
$response['status'] = false;
- $this->log( 'Error message: ' . $file['error'] , 0 );
- } else if ( ! file_exists( $file['file'] ) ) {
+ $this->log( 'Error message: ' . $file['error'], 0 );
+ } elseif ( ! file_exists( $file['file'] ) ) {
$response['status'] = false;
- $this->log( 'The export file could not be found. It is likely that this was caused by a permissions problem.' . $file['error'] , 0 );
+ $this->log( 'The export file could not be found. It is likely that this was caused by a permissions problem.' . $file['error'], 0 );
}
$this->id = (int) $file['id'];
@@ -223,15 +378,70 @@ function handle_upload() {
}
$response['status'] = true;
- $response['file'] = $file['file'];
+ $response['file'] = $file['file'];
$this->log( 'XML parsed with success.', 0 );
+
return $response;
}
-
+
+ /**
+ * Parses the import file.
+ *
+ * @param string $file Import file path.
+ *
+ * @return array|WP_Error
+ */
+ function XMLparse( $file ) {
+ $this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false;
+ $this->authors = $this->posts = $this->term = $this->category = $this->tag = array();
+
+ $this->log( 'XML parser setup.', 0 );
+ $xml = xml_parser_create( 'UTF-8' );
+ xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 );
+ xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 );
+ xml_set_object( $xml, $this );
+ xml_set_character_data_handler( $xml, 'cdata' );
+ xml_set_element_handler( $xml, 'tag_open', 'tag_close' );
+
+ $this->log( 'Parsing content.', 0 );
+ if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) {
+ $current_line = xml_get_current_line_number( $xml );
+ $current_column = xml_get_current_column_number( $xml );
+ $error_code = xml_get_error_code( $xml );
+ $error_string = xml_error_string( $error_code );
+ $this->log( 'There was an error when reading this WXR file.', 0 );
+
+ return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array(
+ $current_line,
+ $current_column,
+ $error_string,
+ ) );
+ }
+ xml_parser_free( $xml );
+
+ if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) {
+ $this->log( 'This does not appear to be a WXR file, missing/invalid WXR version number.', 0 );
+
+ return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
+ }
+
+ $this->log( 'Setting content parameters.', 0 );
+
+ return array(
+ 'authors' => $this->authors,
+ 'posts' => $this->posts,
+ 'categories' => $this->category,
+ 'tags' => $this->tag,
+ 'terms' => $this->term,
+ 'base_url' => $this->base_url,
+ 'version' => $this->wxr_version,
+ );
+ }
+
/**
* The main controller for the actual import stage.
*
- * @param string $file Path to the WXR file for importing
+ * @param string $file Path to the WXR file for importing.
*/
function importContent( $file ) {
@@ -241,57 +451,59 @@ function importContent( $file ) {
$this->get_author_mapping();
wp_suspend_cache_invalidation( true );
-
+
$this->log( 'Process terms start.', 0 );
$this->process_terms();
$this->log( 'Process terms end.', 0 );
-
+
$this->log( 'Process posts start.', 0 );
$this->process_posts();
$this->log( 'Process posts end.', 0 );
-
+
wp_suspend_cache_invalidation( false );
- // update incorrect/missing information in the DB
+ // update incorrect/missing information in the DB.
$this->log( 'Update incorrect/missing information in the DB.', 0 );
-
+
$this->log( 'Update parent/child relations start.', 0 );
$this->backfill_parents();
$this->log( 'Update parent/child relations end.', 0 );
-
+
$this->log( 'Update attachment urls start.', 0 );
$this->backfill_attachment_urls();
$this->log( 'Update attachment urls end.', 0 );
-
+
$this->log( 'Update featured image ids in posts start.', 0 );
$this->remap_featured_images();
$this->log( 'Update featured image ids in posts end.', 0 );
-
+
$this->log( 'Update term image ids in terms start.', 0 );
$this->remap_term_images();
$this->log( 'Update term image ids in terms end.', 0 );
-
+
$this->import_end();
$this->log( 'Import Content function ended.', 0 );
}
-
+
/**
* Parses the WXR file and prepares us for the task of processing parsed data
*
- * @param string $file Path to the WXR file for importing
+ * @param string $file Path to the WXR file for importing.
*/
function import_start( $file ) {
- if ( ! is_file($file) ) {
- $this->import_status = false;
- $this->log( 'The file does not exist, please try again.', 0 );
- return;
+ if ( ! is_file( $file ) ) {
+ $this->import_status = false;
+ $this->log( 'The file does not exist, please try again.', 0 );
+
+ return;
}
$import_data = $this->XMLparse( $file );
if ( is_wp_error( $import_data ) ) {
- $this->import_status = false;
- $this->log( 'Import start error: ' .$import_data->get_error_message(), 0 );
+ $this->import_status = false;
+ $this->log( 'Import start error: ' . $import_data->get_error_message(), 0 );
+
return;
}
@@ -311,21 +523,21 @@ function import_start( $file ) {
do_action( 'import_start' );
}
-
+
/**
* Retrieve authors from parsed WXR data
*
* Uses the provided author information from WXR 1.1 files
* or extracts info from each post for WXR 1.0 files
*
- * @param array $import_data Data returned by a WXR parser
+ * @param array $import_data Data returned by a WXR parser.
*/
function get_authors_from_import( $import_data ) {
$this->log( 'Importing authors start.', 0 );
if ( ! empty( $import_data['authors'] ) ) {
$this->log( 'Authors exists, setting them.', 0 );
$this->authors = $import_data['authors'];
- // no author information, grab it from the posts
+ // no author information, grab it from the posts.
} else {
$this->log( 'Authors does not exist, getting them from posts.', 0 );
foreach ( $import_data['posts'] as $post ) {
@@ -334,17 +546,16 @@ function get_authors_from_import( $import_data ) {
continue;
}
-
- if ( ! isset($this->authors[$login]) )
- $this->authors[$login] = array(
- 'author_login' => $login,
- 'author_display_name' => $post['post_author']
+ if ( ! isset( $this->authors[ $login ] ) ) {
+ $this->authors[ $login ] = array(
+ 'author_login' => $login,
+ 'author_display_name' => $post['post_author'],
);
+ }
}
}
}
-
-
+
/**
* Map old author logins to local user IDs. Can map to an existing user, create a new user
* or falls back to the current user in case of error with either of the previous
@@ -353,42 +564,52 @@ function get_author_mapping() {
$create_users = $this->allow_create_users();
- if ( $create_users && $this->version != '1.0' ) {
+ if ( $create_users && '1.0' != $this->version ) {
$this->log( 'Users creation enabled.', 0 );
- foreach ( $this->authors as $i => $data ) {
-
- $santized_old_login = sanitize_user( $i, true );
- $old_id = isset( $this->authors[$i]['author_id'] ) ? intval($this->authors[$i]['author_id']) : false;
- $this->log( 'Creating user.', 0 );
- $user_data = array(
- 'user_login' => $i,
- 'user_pass' => wp_generate_password(),
- 'user_email' => isset( $this->authors[$i]['author_email'] ) ? $this->authors[$i]['author_email'] : '',
- 'display_name' => $this->authors[$i]['author_display_name'],
- 'first_name' => isset( $this->authors[$i]['author_first_name'] ) ? $this->authors[$i]['author_first_name'] : '',
- 'last_name' => isset( $this->authors[$i]['author_last_name'] ) ? $this->authors[$i]['author_last_name'] : '',
+ foreach ( $this->authors as $i => $data ) {
+
+ $santized_old_login = sanitize_user( $i, true );
+ $old_id = isset( $this->authors[ $i ]['author_id'] ) ? intval( $this->authors[ $i ]['author_id'] ) : false;
+ $this->log( 'Creating user.', 0 );
+ $user_data = array(
+ 'user_login' => $i,
+ 'user_pass' => wp_generate_password(),
+ 'user_email' => isset( $this->authors[ $i ]['author_email'] ) ? $this->authors[ $i ]['author_email'] : '',
+ 'display_name' => $this->authors[ $i ]['author_display_name'],
+ 'first_name' => isset( $this->authors[ $i ]['author_first_name'] ) ? $this->authors[ $i ]['author_first_name'] : '',
+ 'last_name' => isset( $this->authors[ $i ]['author_last_name'] ) ? $this->authors[ $i ]['author_last_name'] : '',
);
- $user_id = wp_insert_user( $user_data );
-
+ $user_id = wp_insert_user( $user_data );
+
if ( ! is_wp_error( $user_id ) ) {
- if ( $old_id ) {
- $this->processed_authors[$old_id] = $user_id;
- }
- $this->author_mapping[$santized_old_login] = $user_id;
+ if ( $old_id ) {
+ $this->processed_authors[ $old_id ] = $user_id;
+ }
+ $this->author_mapping[ $santized_old_login ] = $user_id;
}
-
- // failsafe: if the user_id was invalid, default to the current user
- if ( ! isset( $this->author_mapping[$santized_old_login] ) ) {
- $this->log( 'Some post does not have user assigned, use current user.', 0 );
- if ( $old_id ) {
- $this->processed_authors[$old_id] = (int) get_current_user_id();
- }
- $this->author_mapping[$santized_old_login] = (int) get_current_user_id();
- }
- }
+
+ // failsafe: if the user_id was invalid, default to the current user.
+ if ( ! isset( $this->author_mapping[ $santized_old_login ] ) ) {
+ $this->log( 'Some post does not have user assigned, use current user.', 0 );
+ if ( $old_id ) {
+ $this->processed_authors[ $old_id ] = (int) get_current_user_id();
+ }
+ $this->author_mapping[ $santized_old_login ] = (int) get_current_user_id();
+ }
+ }
}
}
-
+
+ /**
+ * Decide whether or not the importer is allowed to create users.
+ * Default is true, can be filtered via import_allow_create_users
+ *
+ * @return bool True if creating users is allowed
+ */
+ function allow_create_users() {
+ return true;
+ }
+
/**
* Create new terms based on import information
*
@@ -396,17 +617,21 @@ function get_author_mapping() {
*/
function process_terms() {
$this->log( 'Start terms processing.', 0 );
- if ( empty( $this->terms ) )
+ if ( empty( $this->terms ) ) {
return;
+ }
foreach ( $this->terms as $term ) {
$this->log( 'Checking terms.', 0 );
- // if the term already exists in the correct taxonomy leave it alone
+ // if the term already exists in the correct taxonomy leave it alone.
$term_id = term_exists( $term['slug'], $term['term_taxonomy'] );
if ( $term_id ) {
- if ( is_array($term_id) ) $term_id = $term_id['term_id'];
- if ( isset($term['term_id']) )
- $this->processed_terms[intval($term['term_id'])] = (int) $term_id;
+ if ( is_array( $term_id ) ) {
+ $term_id = $term_id['term_id'];
+ }
+ if ( isset( $term['term_id'] ) ) {
+ $this->processed_terms[ intval( $term['term_id'] ) ] = (int) $term_id;
+ }
continue;
}
@@ -414,17 +639,24 @@ function process_terms() {
$parent = 0;
} else {
$parent = term_exists( $term['term_parent'], $term['term_taxonomy'] );
- if ( is_array( $parent ) ) $parent = $parent['term_id'];
+ if ( is_array( $parent ) ) {
+ $parent = $parent['term_id'];
+ }
}
- $term = wp_slash( $term );
+ $term = wp_slash( $term );
$description = isset( $term['term_description'] ) ? $term['term_description'] : '';
- $termarr = array( 'slug' => $term['slug'], 'description' => $description, 'parent' => intval($parent) );
-
+ $termarr = array(
+ 'slug' => $term['slug'],
+ 'description' => $description,
+ 'parent' => intval( $parent ),
+ );
+
$this->log( 'Inserting terms.', 0 );
$id = wp_insert_term( $term['term_name'], $term['term_taxonomy'], $termarr );
if ( ! is_wp_error( $id ) ) {
- if ( isset($term['term_id']) )
- $this->processed_terms[intval($term['term_id'])] = $id['term_id'];
+ if ( isset( $term['term_id'] ) ) {
+ $this->processed_terms[ intval( $term['term_id'] ) ] = $id['term_id'];
+ }
} else {
$this->log( 'Inserting error: ' . $id->get_error_message(), 0 );
continue;
@@ -454,7 +686,7 @@ protected function process_termmeta( $term, $term_id ) {
if ( empty( $term['termmeta'] ) ) {
return;
}
-
+
$this->log( 'Going over term meta.', 0 );
foreach ( $term['termmeta'] as $meta ) {
$key = $meta['key'];
@@ -462,24 +694,24 @@ protected function process_termmeta( $term, $term_id ) {
continue;
}
- // Export gets meta straight from the DB so could have a serialized string
+ // Export gets meta straight from the DB so could have a serialized string.
$value = maybe_unserialize( $meta['value'] );
add_term_meta( $term_id, $key, $value );
-
- if ($key == 'sm_term_image_id') {
+
+ if ( 'sm_term_image_id' == $key ) {
$this->log( 'Term has image id set.', 0 );
- $assigned_term_images = get_option( 'sermon_image_plugin' );
- if( empty($assigned_term_images) ) {
- $assigned_term_images = array();
- }
- $assigned_term_images[$term_id] = $value;
- update_option( 'sermon_image_plugin', $assigned_term_images );
-
- $this->taxonomy_featured_images[$term_id] = (int) $value;
+ $assigned_term_images = get_option( 'sermon_image_plugin' );
+ if ( empty( $assigned_term_images ) ) {
+ $assigned_term_images = array();
+ }
+ $assigned_term_images[ $term_id ] = $value;
+ update_option( 'sermon_image_plugin', $assigned_term_images );
+
+ $this->taxonomy_featured_images[ $term_id ] = (int) $value;
}
}
}
-
+
/**
* Create new posts based on import information
*
@@ -492,15 +724,15 @@ function process_posts() {
foreach ( $this->posts as $post ) {
$this->log( 'Iterating over posts (sermon and attachment).', 0 );
- if ( ! post_type_exists( $post['post_type'] ) && ( $post['post_type'] != 'wpfc_sermon' || $post['post_type'] != 'attachment' ) ) {
+ if ( ! post_type_exists( $post['post_type'] ) && ( 'wpfc_sermon' != $post['post_type'] || 'attachment' != $post['post_type'] ) ) {
continue;
}
- if ( isset( $this->processed_posts[$post['post_id']] ) && ! empty( $post['post_id'] ) ) {
+ if ( isset( $this->processed_posts[ $post['post_id'] ] ) && ! empty( $post['post_id'] ) ) {
continue;
}
- if ( $post['status'] == 'auto-draft' ) {
+ if ( 'auto-draft' == $post['status'] ) {
continue;
}
@@ -509,53 +741,62 @@ function process_posts() {
$post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {
- $comment_post_ID = $post_id = $post_exists;
+ $comment_post_ID = $post_id = $post_exists;
$this->processed_posts[ intval( $post['post_id'] ) ] = intval( $post_exists );
} else {
$post_parent = (int) $post['post_parent'];
if ( $post_parent ) {
- // if we already know the parent, map it to the new local ID
- if ( isset( $this->processed_posts[$post_parent] ) ) {
- $post_parent = $this->processed_posts[$post_parent];
- // otherwise record the parent for later
+ // if we already know the parent, map it to the new local ID.
+ if ( isset( $this->processed_posts[ $post_parent ] ) ) {
+ $post_parent = $this->processed_posts[ $post_parent ];
+ // otherwise record the parent for later.
} else {
- $this->post_orphans[intval($post['post_id'])] = $post_parent;
- $post_parent = 0;
+ $this->post_orphans[ intval( $post['post_id'] ) ] = $post_parent;
+ $post_parent = 0;
}
}
- // map the post author
+ // map the post author.
$author = sanitize_user( $post['post_author'], true );
- if ( isset( $this->author_mapping[$author] ) )
- $author = $this->author_mapping[$author];
- else
+ if ( isset( $this->author_mapping[ $author ] ) ) {
+ $author = $this->author_mapping[ $author ];
+ } else {
$author = (int) get_current_user_id();
+ }
$postdata = array(
- 'import_id' => $post['post_id'], 'post_author' => $author, 'post_date' => $post['post_date'],
- 'post_date_gmt' => $post['post_date_gmt'], 'post_content' => $post['post_content'],
- 'post_excerpt' => $post['post_excerpt'], 'post_title' => $post['post_title'],
- 'post_status' => $post['status'], 'post_name' => $post['post_name'],
- 'comment_status' => $post['comment_status'], 'ping_status' => $post['ping_status'],
- 'guid' => $post['guid'], 'post_parent' => $post_parent, 'menu_order' => $post['menu_order'],
- 'post_type' => $post['post_type'], 'post_password' => $post['post_password']
+ 'import_id' => $post['post_id'],
+ 'post_author' => $author,
+ 'post_date' => $post['post_date'],
+ 'post_date_gmt' => $post['post_date_gmt'],
+ 'post_content' => $post['post_content'],
+ 'post_excerpt' => $post['post_excerpt'],
+ 'post_title' => $post['post_title'],
+ 'post_status' => $post['status'],
+ 'post_name' => $post['post_name'],
+ 'comment_status' => $post['comment_status'],
+ 'ping_status' => $post['ping_status'],
+ 'guid' => $post['guid'],
+ 'post_parent' => $post_parent,
+ 'menu_order' => $post['menu_order'],
+ 'post_type' => $post['post_type'],
+ 'post_password' => $post['post_password'],
);
- $original_post_ID = $post['post_id'];
-
$postdata = wp_slash( $postdata );
if ( 'attachment' == $postdata['post_type'] ) {
- $remote_url = ! empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid'];
+ $remote_url = ! empty( $post['attachment_url'] ) ? $post['attachment_url'] : $post['guid'];
// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
- // e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
+ // e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload().
$postdata['upload_date'] = $post['post_date'];
if ( isset( $post['postmeta'] ) ) {
- foreach( $post['postmeta'] as $meta ) {
- if ( $meta['key'] == '_wp_attached_file' ) {
- if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) )
+ foreach ( $post['postmeta'] as $meta ) {
+ if ( '_wp_attached_file' == $meta['key'] ) {
+ if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) ) {
$postdata['upload_date'] = $matches[0];
+ }
break;
}
}
@@ -570,24 +811,26 @@ function process_posts() {
continue;
}
- if ( $post['is_sticky'] == 1 )
+ if ( 1 == $post['is_sticky'] ) {
stick_post( $post_id );
+ }
}
- // map pre-import ID to local ID
- $this->processed_posts[intval($post['post_id'])] = (int) $post_id;
+ // map pre-import ID to local ID.
+ $this->processed_posts[ intval( $post['post_id'] ) ] = (int) $post_id;
- if ( ! isset( $post['terms'] ) )
+ if ( ! isset( $post['terms'] ) ) {
$post['terms'] = array();
+ }
- // add categories, tags and other terms
+ // add categories, tags and other terms.
if ( ! empty( $post['terms'] ) ) {
$terms_to_set = array();
foreach ( $post['terms'] as $term ) {
- // back compat with WXR 1.0 map 'tag' to 'post_tag'
- $taxonomy = ( 'tag' == $term['domain'] ) ? 'post_tag' : $term['domain'];
+ // back compat with WXR 1.0 map 'tag' to 'post_tag'.
+ $taxonomy = ( 'tag' == $term['domain'] ) ? 'post_tag' : $term['domain'];
$term_exists = term_exists( $term['slug'], $taxonomy );
- $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
+ $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
if ( ! $term_id ) {
$t = wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
if ( ! is_wp_error( $t ) ) {
@@ -596,7 +839,7 @@ function process_posts() {
continue;
}
}
- $terms_to_set[$taxonomy][] = intval( $term_id );
+ $terms_to_set[ $taxonomy ][] = intval( $term_id );
}
foreach ( $terms_to_set as $tax => $ids ) {
@@ -605,77 +848,84 @@ function process_posts() {
unset( $post['terms'], $terms_to_set );
}
- if ( ! isset( $post['comments'] ) )
+ if ( ! isset( $post['comments'] ) ) {
$post['comments'] = array();
+ }
- // add/update comments
+ // add/update comments.
if ( ! empty( $post['comments'] ) ) {
- $num_comments = 0;
+ $num_comments = 0;
$inserted_comments = array();
foreach ( $post['comments'] as $comment ) {
- $comment_id = $comment['comment_id'];
- $newcomments[$comment_id]['comment_post_ID'] = $comment_post_ID;
- $newcomments[$comment_id]['comment_author'] = $comment['comment_author'];
- $newcomments[$comment_id]['comment_author_email'] = $comment['comment_author_email'];
- $newcomments[$comment_id]['comment_author_IP'] = $comment['comment_author_IP'];
- $newcomments[$comment_id]['comment_author_url'] = $comment['comment_author_url'];
- $newcomments[$comment_id]['comment_date'] = $comment['comment_date'];
- $newcomments[$comment_id]['comment_date_gmt'] = $comment['comment_date_gmt'];
- $newcomments[$comment_id]['comment_content'] = $comment['comment_content'];
- $newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
- $newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
- $newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
- $newcomments[$comment_id]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array();
- if ( isset( $this->processed_authors[$comment['comment_user_id']] ) )
- $newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
+ $comment_id = $comment['comment_id'];
+ $newcomments[ $comment_id ]['comment_post_ID'] = $comment_post_ID;
+ $newcomments[ $comment_id ]['comment_author'] = $comment['comment_author'];
+ $newcomments[ $comment_id ]['comment_author_email'] = $comment['comment_author_email'];
+ $newcomments[ $comment_id ]['comment_author_IP'] = $comment['comment_author_IP'];
+ $newcomments[ $comment_id ]['comment_author_url'] = $comment['comment_author_url'];
+ $newcomments[ $comment_id ]['comment_date'] = $comment['comment_date'];
+ $newcomments[ $comment_id ]['comment_date_gmt'] = $comment['comment_date_gmt'];
+ $newcomments[ $comment_id ]['comment_content'] = $comment['comment_content'];
+ $newcomments[ $comment_id ]['comment_approved'] = $comment['comment_approved'];
+ $newcomments[ $comment_id ]['comment_type'] = $comment['comment_type'];
+ $newcomments[ $comment_id ]['comment_parent'] = $comment['comment_parent'];
+ $newcomments[ $comment_id ]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array();
+ if ( isset( $this->processed_authors[ $comment['comment_user_id'] ] ) ) {
+ $newcomments[ $comment_id ]['user_id'] = $this->processed_authors[ $comment['comment_user_id'] ];
+ }
}
ksort( $newcomments );
foreach ( $newcomments as $key => $comment ) {
- // if this is a new post we can skip the comment_exists() check
+ // if this is a new post we can skip the comment_exists() check.
if ( ! $post_exists || ! comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) {
- if ( isset( $inserted_comments[$comment['comment_parent']] ) )
- $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
- $comment = wp_filter_comment( $comment );
- $inserted_comments[$key] = wp_insert_comment( $comment );
+ if ( isset( $inserted_comments[ $comment['comment_parent'] ] ) ) {
+ $comment['comment_parent'] = $inserted_comments[ $comment['comment_parent'] ];
+ }
+ $comment = wp_filter_comment( $comment );
+ $inserted_comments[ $key ] = wp_insert_comment( $comment );
- foreach( $comment['commentmeta'] as $meta ) {
+ foreach ( $comment['commentmeta'] as $meta ) {
$value = maybe_unserialize( $meta['value'] );
- add_comment_meta( $inserted_comments[$key], $meta['key'], $value );
+ add_comment_meta( $inserted_comments[ $key ], $meta['key'], $value );
}
- $num_comments++;
+ $num_comments ++;
}
}
unset( $newcomments, $inserted_comments, $post['comments'] );
}
- if ( ! isset( $post['postmeta'] ) )
+ if ( ! isset( $post['postmeta'] ) ) {
$post['postmeta'] = array();
+ }
- // add/update post meta
+ // add/update post meta.
if ( ! empty( $post['postmeta'] ) ) {
foreach ( $post['postmeta'] as $meta ) {
- $key = $meta['key'];
+ $key = $meta['key'];
$value = false;
if ( '_edit_last' == $key ) {
- if ( isset( $this->processed_authors[intval($meta['value'])] ) )
- $value = $this->processed_authors[intval($meta['value'])];
- else
+ if ( isset( $this->processed_authors[ intval( $meta['value'] ) ] ) ) {
+ $value = $this->processed_authors[ intval( $meta['value'] ) ];
+ } else {
$key = false;
+ }
}
if ( $key ) {
- // export gets meta straight from the DB so could have a serialized string
- if ( ! $value )
+ // export gets meta straight from the DB so could have a serialized string.
+ if ( ! $value ) {
$value = maybe_unserialize( $meta['value'] );
+ }
add_post_meta( $post_id, $key, $value );
- // if the post has a featured image, take note of this in case of remap
- if ( '_thumbnail_id' == $key )
- $this->featured_images[$post_id] = (int) $value;
+ // if the post has a featured image, take note of this in case of remap.
+ if ( '_thumbnail_id' == $key ) {
+ $this->featured_images[ $post_id ] = (int) $value;
+ }
}
}
}
@@ -683,111 +933,134 @@ function process_posts() {
unset( $this->posts );
}
-
+
/**
* If fetching attachments is enabled then attempt to create a new attachment
*
- * @param array $post Attachment post details from WXR
- * @param string $url URL to fetch attachment from
+ * @param array $post Attachment post details from WXR.
+ * @param string $url URL to fetch attachment from.
+ *
* @return int|WP_Error Post ID on success, WP_Error otherwise
*/
function process_attachment( $post, $url ) {
- if ( ! $this->fetch_attachments )
- return new WP_Error( 'attachment_processing_error',
- __( 'Fetching attachments is not enabled', 'wordpress-importer' ) );
+ if ( ! $this->fetch_attachments ) {
+ return new WP_Error( 'attachment_processing_error', __( 'Fetching attachments is not enabled', 'wordpress-importer' ) );
+ }
- // if the URL is absolute, but does not contain address, then upload it assuming base_site_url
- if ( preg_match( '|^/[\w\W]+$|', $url ) )
+ // if the URL is absolute, but does not contain address, then upload it assuming base_site_url.
+ if ( preg_match( '|^/[\w\W]+$|', $url ) ) {
$url = rtrim( $this->base_url, '/' ) . $url;
+ }
$upload = $this->fetch_remote_file( $url, $post );
- if ( is_wp_error( $upload ) )
+ if ( is_wp_error( $upload ) ) {
return $upload;
+ }
- if ( $info = wp_check_filetype( $upload['file'] ) )
+ $info = wp_check_filetype( $upload['file'] );
+ if ( $info ) {
$post['post_mime_type'] = $info['type'];
- else
- return new WP_Error( 'attachment_processing_error', __('Invalid file type', 'wordpress-importer') );
+ } else {
+ return new WP_Error( 'attachment_processing_error', __( 'Invalid file type', 'wordpress-importer' ) );
+ }
$post['guid'] = $upload['url'];
- // as per wp-admin/includes/upload.php
+ // as per `wp-admin/includes/upload.php`.
$post_id = wp_insert_attachment( $post, $upload['file'] );
wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) );
// remap resized image URLs, works by stripping the extension and remapping the URL stub.
if ( preg_match( '!^image/!', $info['type'] ) ) {
$parts = pathinfo( $url );
- $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2
+ $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2.
$parts_new = pathinfo( $upload['url'] );
- $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" );
+ $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" );
- $this->url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new;
+ $this->url_remap[ $parts['dirname'] . '/' . $name ] = $parts_new['dirname'] . '/' . $name_new;
}
return $post_id;
}
-
+
/**
* Attempt to download a remote file attachment
*
- * @param string $url URL of item to fetch
- * @param array $post Attachment details
+ * @param string $url URL of item to fetch.
+ * @param array $post Attachment details.
+ *
* @return array|WP_Error Local file location details on success, WP_Error otherwise
*/
function fetch_remote_file( $url, $post ) {
- // extract the file name and extension from the url
+ // extract the file name and extension from the url.
$file_name = basename( $url );
- // get placeholder file in the upload dir with a unique, sanitized filename
+ // get placeholder file in the upload dir with a unique, sanitized filename.
$upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
- if ( $upload['error'] )
+ if ( $upload['error'] ) {
return new WP_Error( 'upload_dir_error', $upload['error'] );
+ }
- // fetch the remote url and write it to the placeholder file
+ // fetch the remote url and write it to the placeholder file.
$headers = wp_get_http( $url, $upload['file'] );
- // request failed
+ // request failed.
if ( ! $headers ) {
@unlink( $upload['file'] );
- return new WP_Error( 'import_file_error', __('Remote server did not respond', 'wordpress-importer') );
+
+ return new WP_Error( 'import_file_error', __( 'Remote server did not respond', 'wordpress-importer' ) );
}
- // make sure the fetch was successful
+ // make sure the fetch was successful.
if ( $headers['response'] != '200' ) {
@unlink( $upload['file'] );
- return new WP_Error( 'import_file_error', sprintf( __('Remote server returned error response %1$d %2$s', 'wordpress-importer'), esc_html($headers['response']), get_status_header_desc($headers['response']) ) );
+
+ return new WP_Error( 'import_file_error', sprintf( __( 'Remote server returned error response %1$d %2$s', 'wordpress-importer' ), esc_html( $headers['response'] ), get_status_header_desc( $headers['response'] ) ) );
}
$filesize = filesize( $upload['file'] );
if ( isset( $headers['content-length'] ) && $filesize != $headers['content-length'] ) {
@unlink( $upload['file'] );
- return new WP_Error( 'import_file_error', __('Remote file is incorrect size', 'wordpress-importer') );
+
+ return new WP_Error( 'import_file_error', __( 'Remote file is incorrect size', 'wordpress-importer' ) );
}
if ( 0 == $filesize ) {
@unlink( $upload['file'] );
- return new WP_Error( 'import_file_error', __('Zero size file downloaded', 'wordpress-importer') );
+
+ return new WP_Error( 'import_file_error', __( 'Zero size file downloaded', 'wordpress-importer' ) );
}
$max_size = (int) $this->max_attachment_size();
if ( ! empty( $max_size ) && $filesize > $max_size ) {
@unlink( $upload['file'] );
- return new WP_Error( 'import_file_error', sprintf(__('Remote file is too large, limit is %s', 'wordpress-importer'), size_format($max_size) ) );
+
+ return new WP_Error( 'import_file_error', sprintf( __( 'Remote file is too large, limit is %s', 'wordpress-importer' ), size_format( $max_size ) ) );
}
- // keep track of the old and new urls so we can substitute them later
- $this->url_remap[$url] = $upload['url'];
- $this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed?
- // keep track of the destination if the remote url is redirected somewhere else
- if ( isset($headers['x-final-location']) && $headers['x-final-location'] != $url )
- $this->url_remap[$headers['x-final-location']] = $upload['url'];
+ // keep track of the old and new urls so we can substitute them later.
+ $this->url_remap[ $url ] = $upload['url'];
+ $this->url_remap[ $post['guid'] ] = $upload['url']; // r13735, really needed?
+ // keep track of the destination if the remote url is redirected somewhere else.
+ if ( isset( $headers['x-final-location'] ) && $headers['x-final-location'] != $url ) {
+ $this->url_remap[ $headers['x-final-location'] ] = $upload['url'];
+ }
return $upload;
}
-
+
+ /**
+ * Decide what the maximum file size for downloaded attachments is.
+ * Default is 0 (unlimited), can be filtered via import_attachment_size_limit
+ *
+ * @return int Maximum attachment file size to import
+ */
+ function max_attachment_size() {
+ return 0;
+ }
+
/**
* Attempt to associate posts with previously missing parents
*
@@ -797,73 +1070,73 @@ function fetch_remote_file( $url, $post ) {
function backfill_parents() {
global $wpdb;
- // find parents for post orphans
+ // find parents for post orphans.
foreach ( $this->post_orphans as $child_id => $parent_id ) {
$local_child_id = $local_parent_id = false;
- if ( isset( $this->processed_posts[$child_id] ) )
- $local_child_id = $this->processed_posts[$child_id];
- if ( isset( $this->processed_posts[$parent_id] ) )
- $local_parent_id = $this->processed_posts[$parent_id];
+ if ( isset( $this->processed_posts[ $child_id ] ) ) {
+ $local_child_id = $this->processed_posts[ $child_id ];
+ }
+ if ( isset( $this->processed_posts[ $parent_id ] ) ) {
+ $local_parent_id = $this->processed_posts[ $parent_id ];
+ }
- if ( $local_child_id && $local_parent_id )
+ if ( $local_child_id && $local_parent_id ) {
$wpdb->update( $wpdb->posts, array( 'post_parent' => $local_parent_id ), array( 'ID' => $local_child_id ), '%d', '%d' );
+ }
}
}
-
+
+ // return the difference in length between two strings.
/**
* Use stored mapping information to update old attachment URLs
*/
function backfill_attachment_urls() {
global $wpdb;
- // make sure we do the longest urls first, in case one is a substring of another
- uksort( $this->url_remap, array(&$this, 'cmpr_strlen') );
+ // make sure we do the longest urls first, in case one is a substring of another.
+ uksort( $this->url_remap, array( &$this, 'cmpr_strlen' ) );
foreach ( $this->url_remap as $from_url => $to_url ) {
- // remap urls in post_content
- $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url) );
- // remap enclosure urls
- $result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url) );
+ // remap urls in post_content.
+ $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url ) );
+ // remap enclosure urls.
+ $result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url ) );
}
}
-
- // return the difference in length between two strings
- function cmpr_strlen( $a, $b ) {
- return strlen($b) - strlen($a);
- }
-
+
/**
* Update _thumbnail_id meta to new, imported attachment IDs
*/
function remap_featured_images() {
- // cycle through posts that have a featured image
+ // cycle through posts that have a featured image.
foreach ( $this->featured_images as $post_id => $value ) {
- if ( isset( $this->processed_posts[$value] ) ) {
- $new_id = $this->processed_posts[$value];
- // only update if there's a difference
- if ( $new_id != $value )
+ if ( isset( $this->processed_posts[ $value ] ) ) {
+ $new_id = $this->processed_posts[ $value ];
+ // only update if there's a difference.
+ if ( $new_id != $value ) {
update_post_meta( $post_id, '_thumbnail_id', $new_id );
+ }
}
}
}
-
+
/**
* Update sm_term_image_id meta to new, imported attachment IDs
*/
function remap_term_images() {
- // cycle through posts that have a featured image
+ // cycle through posts that have a featured image.
foreach ( $this->taxonomy_featured_images as $term_id => $value ) {
- if ( isset( $this->processed_posts[$value] ) ) {
- $new_id = $this->processed_posts[$value];
- // only update if there's a difference
+ if ( isset( $this->processed_posts[ $value ] ) ) {
+ $new_id = $this->processed_posts[ $value ];
+ // only update if there's a difference.
if ( $new_id != $value ) {
- $assigned_term_images = get_option( 'sermon_image_plugin' );
- $assigned_term_images[$term_id] = $new_id;
- update_option( 'sermon_image_plugin', $assigned_term_images );
+ $assigned_term_images = get_option( 'sermon_image_plugin' );
+ $assigned_term_images[ $term_id ] = $new_id;
+ update_option( 'sermon_image_plugin', $assigned_term_images );
}
}
}
}
-
+
/**
* Performs post-import cleanup of files and the cache
*/
@@ -881,85 +1154,70 @@ function import_end() {
do_action( 'import_end' );
}
-
- /* WXR Functions - Start */
-
- function XMLparse( $file ) {
- $this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false;
- $this->authors = $this->posts = $this->term = $this->category = $this->tag = array();
- $this->log( 'XML parser setup.', 0 );
- $xml = xml_parser_create( 'UTF-8' );
- xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 );
- xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 );
- xml_set_object( $xml, $this );
- xml_set_character_data_handler( $xml, 'cdata' );
- xml_set_element_handler( $xml, 'tag_open', 'tag_close' );
-
- $this->log( 'Parsing content.', 0 );
- if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) {
- $current_line = xml_get_current_line_number( $xml );
- $current_column = xml_get_current_column_number( $xml );
- $error_code = xml_get_error_code( $xml );
- $error_string = xml_error_string( $error_code );
- $this->log( 'There was an error when reading this WXR file.', 0 );
- return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) );
- }
- xml_parser_free( $xml );
-
- if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) {
- $this->log( 'This does not appear to be a WXR file, missing/invalid WXR version number.', 0 );
- return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
- }
-
- $this->log( 'Setting content parameters.', 0 );
- return array(
- 'authors' => $this->authors,
- 'posts' => $this->posts,
- 'categories' => $this->category,
- 'tags' => $this->tag,
- 'terms' => $this->term,
- 'base_url' => $this->base_url,
- 'version' => $this->wxr_version
- );
+ /* WXR Functions - Start */
+ function cmpr_strlen( $a, $b ) {
+ return strlen( $b ) - strlen( $a );
}
-
+
function tag_open( $parse, $tag, $attr ) {
$this->log( 'Opening tags.', 0 );
if ( in_array( $tag, $this->wp_tags ) ) {
$this->in_tag = substr( $tag, 3 );
+
return;
}
if ( in_array( $tag, $this->wp_sub_tags ) ) {
$this->in_sub_tag = substr( $tag, 3 );
+
return;
}
switch ( $tag ) {
case 'category':
- if ( isset($attr['domain'], $attr['nicename']) ) {
+ if ( isset( $attr['domain'], $attr['nicename'] ) ) {
$this->sub_data['domain'] = $attr['domain'];
- $this->sub_data['slug'] = $attr['nicename'];
+ $this->sub_data['slug'] = $attr['nicename'];
+ }
+ break;
+ case 'item':
+ $this->in_post = true;
+ case 'title':
+ if ( $this->in_post ) {
+ $this->in_tag = 'post_title';
}
break;
- case 'item': $this->in_post = true;
- case 'title': if ( $this->in_post ) $this->in_tag = 'post_title'; break;
- case 'guid': $this->in_tag = 'guid'; break;
- case 'dc:creator': $this->in_tag = 'post_author'; break;
- case 'content:encoded': $this->in_tag = 'post_content'; break;
- case 'excerpt:encoded': $this->in_tag = 'post_excerpt'; break;
-
- case 'wp:term_slug': $this->in_tag = 'slug'; break;
- case 'wp:meta_key': $this->in_sub_tag = 'key'; break;
- case 'wp:meta_value': $this->in_sub_tag = 'value'; break;
+ case 'guid':
+ $this->in_tag = 'guid';
+ break;
+ case 'dc:creator':
+ $this->in_tag = 'post_author';
+ break;
+ case 'content:encoded':
+ $this->in_tag = 'post_content';
+ break;
+ case 'excerpt:encoded':
+ $this->in_tag = 'post_excerpt';
+ break;
+
+ case 'wp:term_slug':
+ $this->in_tag = 'slug';
+ break;
+ case 'wp:meta_key':
+ $this->in_sub_tag = 'key';
+ break;
+ case 'wp:meta_value':
+ $this->in_sub_tag = 'value';
+ break;
}
}
function cdata( $parser, $cdata ) {
$this->log( 'Handling data.', 0 );
- if ( ! trim( $cdata ) )
+ if ( ! trim( $cdata ) ) {
return;
+ }
if ( false !== $this->in_tag || false !== $this->in_sub_tag ) {
$this->cdata .= $cdata;
@@ -973,36 +1231,39 @@ function tag_close( $parser, $tag ) {
switch ( $tag ) {
case 'wp:comment':
unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data
- if ( ! empty( $this->sub_data ) )
+ if ( ! empty( $this->sub_data ) ) {
$this->data['comments'][] = $this->sub_data;
+ }
$this->sub_data = false;
break;
case 'wp:commentmeta':
$this->sub_data['commentmeta'][] = array(
- 'key' => $this->sub_data['key'],
+ 'key' => $this->sub_data['key'],
'value' => $this->sub_data['value']
);
break;
case 'category':
if ( ! empty( $this->sub_data ) ) {
$this->sub_data['name'] = $this->cdata;
- $this->data['terms'][] = $this->sub_data;
+ $this->data['terms'][] = $this->sub_data;
}
$this->sub_data = false;
break;
case 'wp:postmeta':
- if ( ! empty( $this->sub_data ) )
+ if ( ! empty( $this->sub_data ) ) {
$this->data['postmeta'][] = $this->sub_data;
+ }
$this->sub_data = false;
break;
case 'wp:termmeta':
- if ( ! empty( $this->sub_data ) )
+ if ( ! empty( $this->sub_data ) ) {
$this->data['termmeta'][] = $this->sub_data;
+ }
$this->sub_data = false;
break;
case 'item':
$this->posts[] = $this->data;
- $this->data = false;
+ $this->data = false;
break;
case 'wp:category':
case 'wp:tag':
@@ -1012,8 +1273,9 @@ function tag_close( $parser, $tag ) {
$this->data = false;
break;
case 'wp:author':
- if ( ! empty($this->data['author_login']) )
- $this->authors[$this->data['author_login']] = $this->data;
+ if ( ! empty( $this->data['author_login'] ) ) {
+ $this->authors[ $this->data['author_login'] ] = $this->data;
+ }
$this->data = false;
break;
case 'wp:base_site_url':
@@ -1025,16 +1287,16 @@ function tag_close( $parser, $tag ) {
default:
if ( $this->in_sub_tag ) {
- $this->sub_data[$this->in_sub_tag] = ! empty( $this->cdata ) ? $this->cdata : '';
- $this->in_sub_tag = false;
- } else if ( $this->in_tag ) {
- $this->data[$this->in_tag] = ! empty( $this->cdata ) ? $this->cdata : '';
- $this->in_tag = false;
+ $this->sub_data[ $this->in_sub_tag ] = ! empty( $this->cdata ) ? $this->cdata : '';
+ $this->in_sub_tag = false;
+ } elseif ( $this->in_tag ) {
+ $this->data[ $this->in_tag ] = ! empty( $this->cdata ) ? $this->cdata : '';
+ $this->in_tag = false;
}
}
$this->cdata = false;
}
-
+
/* WXR Functions - End */
}
\ No newline at end of file
diff --git a/includes/admin/settings/class-sm-settings-debug.php b/includes/admin/settings/class-sm-settings-debug.php
index f339418..66208e8 100644
--- a/includes/admin/settings/class-sm-settings-debug.php
+++ b/includes/admin/settings/class-sm-settings-debug.php
@@ -1,10 +1,19 @@
id = 'debug';
$this->label = __( 'Debug', 'sermon-manager-for-wordpress' );
@@ -23,13 +32,7 @@ public function get_settings() {
'title' => __( 'Debug Settings', 'sermon-manager-for-wordpress' ),
'type' => 'title',
'desc' => '',
- 'id' => 'debug_settings'
- ),
- array(
- 'title' => __( 'Enable output of PHP errors in Sermon Manager (disable in production)', 'sermon-manager-for-wordpress' ),
- 'type' => 'checkbox',
- 'id' => 'sm_debug',
- 'default' => 'no',
+ 'id' => 'debug_settings',
),
array(
'title' => __( 'Force Sermon Manager\'s WP_Background_Updater class', 'sermon-manager-for-wordpress' ),
@@ -48,7 +51,7 @@ public function get_settings() {
'title' => __( 'Enable book sorting in dropdown box' ),
'type' => 'checkbox',
'id' => 'sort_bible_books',
- 'default' => 'yes'
+ 'default' => 'yes',
),
array(
'title' => __( 'Execute all update functions that have not been executed yet' ),
@@ -63,23 +66,11 @@ public function get_settings() {
1 => 'Enable',
11 => 'Enable and re-create all',
0 => 'Disable',
- 10 => 'Disable and flush existing'
+ 10 => 'Disable and flush existing',
),
'id' => 'post_content_enabled',
'default' => 1,
),
- array(
- 'title' => '"post_excerpt" creation',
- 'type' => 'select',
- 'options' => array(
- 1 => 'Enable',
- 11 => 'Enable and re-create all',
- 0 => 'Disable',
- 10 => 'Disable and flush existing'
- ),
- 'id' => 'post_excerpt_enabled',
- 'default' => 1,
- ),
array(
'title' => 'Use home_url in dropdown filter',
'type' => 'checkbox',
@@ -116,7 +107,10 @@ public function get_settings() {
'default' => 0,
),
- array( 'type' => 'sectionend', 'id' => 'debug_settings' ),
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'debug_settings',
+ ),
) );
return apply_filters( 'sm_get_settings_' . $this->id, $settings );
diff --git a/includes/admin/settings/class-sm-settings-general.php b/includes/admin/settings/class-sm-settings-general.php
index c8ff612..bac5d92 100644
--- a/includes/admin/settings/class-sm-settings-general.php
+++ b/includes/admin/settings/class-sm-settings-general.php
@@ -1,10 +1,19 @@
id = 'general';
$this->label = __( 'General', 'sermon-manager-for-wordpress' );
@@ -24,12 +33,13 @@ public function get_settings() {
'title' => __( 'General Settings', 'sermon-manager-for-wordpress' ),
'type' => 'title',
'desc' => '',
- 'id' => 'general_settings'
+ 'id' => 'general_settings',
),
array(
'title' => __( 'Archive Page Slug', 'sermon-manager-for-wordpress' ),
'type' => 'text',
'id' => 'archive_slug',
+ // translators: %s: Archive page title, default: "Sermons".
'placeholder' => wp_sprintf( __( 'e.g. %s', 'sermon-manager-for-wordpress' ), sanitize_title( __( 'Sermons', 'sermon-manager-for-wordpress' ) ) ),
'default' => 'sermons',
),
@@ -37,8 +47,8 @@ public function get_settings() {
'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
+ // 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',
'default' => 'no',
@@ -55,8 +65,8 @@ public function get_settings() {
'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
' ),
+ // 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' ), '/assets/css/sermon.min.css
' ),
'id' => 'css',
'default' => 'no',
),
@@ -73,7 +83,7 @@ public function get_settings() {
'default' => 'no',
),
array(
- 'title' => __( 'Display Service Type filtering on archive pages', 'sermon-manager-for-wordpress' ),
+ 'title' => __( 'Display Service Type filtering on archive pages', 'sermon-manager-for-wordpress' ),
'type' => 'checkbox',
'id' => 'service_type_filtering',
'default' => 'no',
@@ -86,7 +96,7 @@ public function get_settings() {
'options' => array(
'plyr' => 'Plyr',
'mediaelement' => 'Mediaelement',
- 'wordpress' => 'Old WordPress player',
+ 'WordPress' => 'Old WordPress player',
'none' => 'Browser HTML5',
),
'default' => 'plyr',
@@ -109,7 +119,7 @@ public function get_settings() {
'2' => 'YY/mm/dd',
'3' => 'YY/dd/mm',
),
- 'default' => '0'
+ 'default' => '0',
),
array(
'title' => __( 'Disable sermon image on archive view', 'sermon-manager-for-wordpress' ),
@@ -119,13 +129,22 @@ public function get_settings() {
'default' => 'no',
),
array(
- 'title' => __( 'Disable sermon image on single sermon view', 'sermon-manager-for-wordpress' ),
- 'type' => 'checkbox',
- 'id' => 'disable_image_single',
- 'default' => 'no',
+ 'title' => __( 'Disable sermon image on single sermon view', 'sermon-manager-for-wordpress' ),
+ 'type' => 'checkbox',
+ 'id' => 'disable_image_single',
+ 'default' => 'no',
+ ),
+ array(
+ 'title' => __( 'Do not show read more when all the text is visible', 'sermon-manager-for-wordpress' ),
+ 'type' => 'checkbox',
+ 'id' => 'hide_read_more_when_not_needed',
+ 'default' => 'no',
),
- array( 'type' => 'sectionend', 'id' => 'general_settings' ),
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'general_settings',
+ ),
) );
return apply_filters( 'sm_get_settings_' . $this->id, $settings );
diff --git a/includes/admin/settings/class-sm-settings-import.php b/includes/admin/settings/class-sm-settings-import.php
new file mode 100644
index 0000000..e5dcffc
--- /dev/null
+++ b/includes/admin/settings/class-sm-settings-import.php
@@ -0,0 +1,63 @@
+id = 'import';
+ $this->label = __( 'Import', 'sermon-manager-for-wordpress' );
+
+ parent::__construct();
+ }
+
+ /**
+ * Get settings array.
+ *
+ * @return array
+ */
+ public function get_settings() {
+ $settings = apply_filters( 'sm_import_settings', array(
+ array(
+ 'title' => __( 'Import Settings', 'sermon-manager-for-wordpress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'import_settings',
+ ),
+ array(
+ 'title' => 'Disallow comments by default',
+ 'type' => 'checkbox',
+ 'id' => 'import_disallow_comments',
+ 'default' => 'no',
+ ),
+ array(
+ 'title' => 'Do not mark preached dates as auto update',
+ 'type' => 'checkbox',
+ 'desc' => __( 'If checked, it will show date preached in Edit Sermon view, but it will not auto-update them when Date Published changes.', 'sermon-manager-for-wordpress' ),
+ 'id' => 'import_disable_auto_dates',
+ 'default' => 'no',
+ ),
+
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'verse_settings',
+ ),
+ ) );
+
+ return apply_filters( 'sm_get_settings_' . $this->id, $settings );
+ }
+}
+
+return new SM_Settings_Import();
diff --git a/includes/admin/settings/class-sm-settings-page.php b/includes/admin/settings/class-sm-settings-page.php
index 659eb14..5e49535 100644
--- a/includes/admin/settings/class-sm-settings-page.php
+++ b/includes/admin/settings/class-sm-settings-page.php
@@ -1,17 +1,31 @@
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
index 08d8a88..123d244 100644
--- a/includes/admin/settings/class-sm-settings-podcast.php
+++ b/includes/admin/settings/class-sm-settings-podcast.php
@@ -1,10 +1,19 @@
id = 'podcast';
$this->label = __( 'Podcast', 'sermon-manager-for-wordpress' );
@@ -54,7 +63,9 @@ public function get_settings() {
'title' => __( 'Copyright', 'sermon-manager-for-wordpress' ),
'type' => 'text',
'id' => 'copyright',
+ // translators: %s: blog name.
'placeholder' => wp_sprintf( __( 'Copyright © %s', 'sermon-manager-for-wordpress' ), get_bloginfo( 'name' ) ),
+ // translators: %s: copyright symbol HTML entitiy (©).
'desc' => wp_sprintf( esc_html__( 'Tip: Use %s to generate a copyright symbol.', 'sermon-manager-for-wordpress' ), '' . htmlspecialchars( '©' ) . '
' ),
),
array(
@@ -80,6 +91,7 @@ public function get_settings() {
'title' => __( 'Subtitle', 'sermon-manager-for-wordpress' ),
'type' => 'text',
'id' => 'itunes_subtitle',
+ // translators: %s: blog name.
'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' ),
),
@@ -87,9 +99,8 @@ public function get_settings() {
'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' ) ),
+ // translators: %s: blog name.
+ '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(
@@ -132,17 +143,17 @@ public function get_settings() {
'type' => 'checkbox',
'id' => 'podtrac',
'desc' => __( 'Enables PodTrac tracking.', 'sermon-manager-for-wordpress' ),
- // translators: %s podtrac.com
+ // 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 ' ),
- 'default' => 'no',
+ 'default' => 'no',
),
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' ),
- 'desc_tip' => __( 'It is recommended to leave it unchecked.', 'sermon-manager-for-wordpress' ),
- 'default' => 'no',
+ 'desc_tip' => __( 'It is recommended to leave it unchecked. Uncheck if the feed does not validate.', 'sermon-manager-for-wordpress' ),
+ 'default' => 'no',
),
array(
'title' => __( 'Redirect', 'sermon-manager-for-wordpress' ),
@@ -168,37 +179,51 @@ public function get_settings() {
'placeholder' => get_option( 'posts_per_rss' ),
),
- array( 'type' => 'sectionend', 'id' => 'podcast_settings' ),
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'podcast_settings',
+ ),
) );
return apply_filters( 'sm_get_settings_' . $this->id, $settings );
}
+ /**
+ * Additional HTML after the settings form.
+ */
public function after() {
?>
-
-
- = __( 'Feed URL to Submit to iTunes', 'sermon-manager-for-wordpress' ) ?>
-
-
-
- = // translators: %s Feed Validator link, see msgid "Feed Validator"
- wp_sprintf( esc_html__( 'Use the %s to diagnose and fix any problems before submitting your Podcast to iTunes.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Feed Validator', 'sermon-manager-for-wordpress' ) . ' ' ) ?>
-
-
- = // translators: %s see msgid "Submit Your Podcast"
- wp_sprintf( esc_html__( 'Once your Podcast Settings are complete and your Sermons are ready, it’s time to %s to the iTunes Store!', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Submit Your Podcast', 'sermon-manager-for-wordpress' ) . ' ' ) ?>
-
-
- = // translators: %s see msgid "FeedBurner"
- wp_sprintf( esc_html__( 'Alternatively, if you want to track your Podcast subscribers, simply pass the Podcast Feed URL above through %s. FeedBurner will then give you a new URL to submit to iTunes instead.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'FeedBurner', 'sermon-manager-for-wordpress' ) . ' ' ) ?>
-
-
- = // translators: %s see msgid "iTunes FAQ for Podcast Makers"
- wp_sprintf( esc_html__( 'Please read the %s for more information.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'iTunes FAQ for Podcast Makers', 'sermon-manager-for-wordpress' ) . ' ' ) ?>
-
-
+
+
+
+
+
+
+ ' . 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' );
@@ -19,16 +28,16 @@ public function __construct() {
*/
public function get_settings() {
if ( strpos( get_locale(), 'es_' ) !== false ) {
- // Add Spanish Bible translations
+ // Add Spanish Bible translations.
add_filter( 'sm_verse_settings', function ( $settings ) {
foreach ( $settings as &$setting ) {
- if ( $setting['id'] === 'verse_bible_version' ) {
+ if ( 'verse_bible_version' === $setting['id'] ) {
$setting['options'] = array_merge( array(
'LBLA95' => 'LBLA95',
'NBLH' => 'NBLH',
'NVI' => 'NVI',
'RVR60' => 'RVR60',
- 'RVA' => 'RVA'
+ 'RVA' => 'RVA',
), $setting['options'] );
$setting['default'] = 'NVI';
@@ -41,10 +50,10 @@ public function get_settings() {
} );
} else {
// Check if Spanish Bible translation was selected previously,
- // and if it was - append it to the list
+ // and if it was - append it to the list.
add_filter( 'sm_verse_settings', function ( $settings ) {
foreach ( $settings as &$setting ) {
- if ( $setting['id'] === 'verse_bible_version' ) {
+ if ( 'verse_bible_version' === $setting['id'] ) {
switch ( SermonManager::getOption( 'verse_bible_version' ) ) {
case $setting['default']:
case '':
@@ -56,12 +65,12 @@ public function get_settings() {
'NBLH',
'NVI',
'RVR60',
- 'RVA'
+ 'RVA',
) as $value
) {
if ( SermonManager::getOption( 'verse_bible_version' ) === $value ) {
$setting['options'] = array_merge( array(
- $value => $value
+ $value => $value,
), $setting['options'] );
$setting['desc'] = __( 'Note: WordPress is not set to any Spanish variant. Reverted to ESV.', 'sermon-manager-for-wordpress' );
@@ -82,7 +91,7 @@ public function get_settings() {
'title' => __( 'Verse Settings', 'sermon-manager-for-wordpress' ),
'type' => 'title',
'desc' => '',
- 'id' => 'verse_settings'
+ 'id' => 'verse_settings',
),
array(
'title' => __( 'Verse Popups', 'sermon-manager-for-wordpress' ),
@@ -122,7 +131,10 @@ public function get_settings() {
'id' => 'widget_show_key_verse',
),
- array( 'type' => 'sectionend', 'id' => 'verse_settings' ),
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'verse_settings',
+ ),
) );
return apply_filters( 'sm_get_settings_' . $this->id, $settings );
diff --git a/includes/admin/sm-admin-functions.php b/includes/admin/sm-admin-functions.php
index 0209ecc..3031aae 100644
--- a/includes/admin/sm-admin-functions.php
+++ b/includes/admin/sm-admin-functions.php
@@ -1,4 +1,10 @@
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 = '';
+
+ if ( current_user_can( 'edit_posts' ) ) {
+ $count .= '' . $text . ' ';
+ } else {
+ $count .= $text;
+ }
+
+ $count .= ' ';
+ $count .= "";
+ echo $count;
+}
+
+add_action( 'dashboard_glance_items', 'wpfc_dashboard' );
+
+/**
+ * Register required actions.
+ */
+function wpfc_taxonomy_short_description_actions() {
+ $taxonomies = get_taxonomies();
+ foreach ( $taxonomies as $taxonomy ) {
+ if ( ! in_array( $taxonomy, array(
+ 'wpfc_preacher',
+ 'wpfc_sermon_series',
+ 'wpfc_sermon_topics',
+ 'wpfc_bible_book',
+ 'wpfc_service_type',
+ ) ) ) {
+ continue;
+ }
+
+ add_action( 'manage_' . $taxonomy . '_custom_column', 'wpfc_taxonomy_short_description_rows', 100, 3 );
+ add_action( 'manage_edit-' . $taxonomy . '_columns', 'wpfc_taxonomy_short_description_columns' );
+ add_filter( 'manage_edit-' . $taxonomy . '_sortable_columns', 'wpfc_taxonomy_short_description_columns' );
+ }
+}
+
+add_action( 'admin_init', 'wpfc_taxonomy_short_description_actions' );
+
+/**
+ * Replace existing column with custom so it can be modified.
+ *
+ * @param array $columns Existing columns.
+ *
+ * @return array
+ */
+function wpfc_taxonomy_short_description_columns( $columns ) {
+ $position = 0;
+ $iterator = 1;
+ foreach ( $columns as $column => $display_name ) {
+ if ( 'name' == $column ) {
+ $position = $iterator;
+ break;
+ }
+ $iterator ++;
+ }
+ if ( 0 < $position ) {
+ $columns = array_slice( $columns, 0, $position, true ) + array( 'short_description' => 'Description' ) + array_slice( $columns, $position + 1, count( $columns ) - 1, true );
+
+ return $columns;
+ }
+
+ return $columns;
+}
+
+/**
+ * Add short description content.
+ *
+ * @param mixed $default Default content.
+ * @param string $column_name Column name.
+ * @param int $term Term ID.
+ *
+ * @return mixed|string
+ */
+function wpfc_taxonomy_short_description_rows( $default, $column_name, $term ) {
+ if ( 'short_description' == $column_name ) {
+ global $taxonomy;
+ $default = term_description( $term, $taxonomy );
+ $default = wp_trim_words( $default, 10 );
+ }
+
+ return $default;
+}
diff --git a/includes/sm-cmb-functions.php b/includes/admin/sm-cmb-functions.php
similarity index 59%
rename from includes/sm-cmb-functions.php
rename to includes/admin/sm-cmb-functions.php
index dc5f76d..ff26633 100755
--- a/includes/sm-cmb-functions.php
+++ b/includes/admin/sm-cmb-functions.php
@@ -1,66 +1,24 @@
'category' );
-
- $taxonomy = $args['taxonomy'];
- $args = array(
- 'hide_empty' => false
- );
+defined( 'ABSPATH' ) or die;
- $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
+/**
+ * Define the metaboxes 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
+ '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
+ 'show_names' => true, // Show field names on the left.
) );
switch ( \SermonManager::getOption( 'date_format' ) ) {
@@ -88,8 +46,8 @@ function wpfc_sermon_metaboxes() {
$cmb->add_field( array(
'name' => esc_html__( 'Date Preached', 'sermon-manager-for-wordpress' ),
- '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_label ),
+ // translators: %s date format, effectively d/m/Y
or the like.
+ 'desc' => esc_html__( '(optional)', 'sermon-manager-for-wordpress' ) . ' ' . wp_sprintf( esc_html__( 'format: %s', 'sermon-manager-for-wordpress' ), $date_format_label ),
'id' => 'sermon_date',
'type' => 'text_date_timestamp',
'date_format' => $date_format,
@@ -97,17 +55,18 @@ function wpfc_sermon_metaboxes() {
$cmb->add_field( array(
'name' => esc_html__( 'Service Type', '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 ' ),
+ // 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,
'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( /* 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' ) . '
' ),
+ // translators: %s see msgid "John 3:16-18", effectively John 3:16-18
.
+ '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',
) );
@@ -116,18 +75,19 @@ function wpfc_sermon_metaboxes() {
'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, ),
+ '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
+ 'object_types' => array( 'wpfc_sermon' ),
'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
+ 'show_names' => true,
) );
$cmb2->add_field( array(
'name' => esc_html__( 'Location of MP3', 'sermon-manager-for-wordpress' ),
@@ -135,13 +95,13 @@ function wpfc_sermon_metaboxes() {
'id' => 'sermon_audio',
'type' => 'file',
'text' => array(
- 'add_upload_file_text' => 'Add Sermon Audio' // Change upload button text. Default: "Add or Upload File"
+ 'add_upload_file_text' => 'Add Sermon Audio', // 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( /* 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' ) . '
' ),
+ // translators: %s see msgid "hh:mm:ss", effectively hh:mm:ss
.
+ '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',
) );
@@ -149,23 +109,22 @@ function wpfc_sermon_metaboxes() {
'name' => esc_html__( 'Video Embed Code', 'sermon-manager-for-wordpress' ),
'desc' => esc_html__( 'Paste your embed code for Vimeo, Youtube, Facebook, or direct video file here', 'sermon-manager-for-wordpress' ),
'id' => 'sermon_video',
- 'type' => 'textarea_code'
+ '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, Facebook, or direct video file here', 'sermon-manager-for-wordpress' ),
- 'id' => 'sermon_video_link',
- 'type' => 'text_url'
- ) )
- );
+ 'name' => esc_html__( 'Video Link', 'sermon-manager-for-wordpress' ),
+ 'desc' => esc_html__( 'Paste your link for Vimeo, Youtube, Facebook, or direct video file here', 'sermon-manager-for-wordpress' ),
+ 'id' => 'sermon_video_link',
+ 'type' => 'text_url',
+ ) ) );
$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' => 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(
@@ -174,8 +133,54 @@ 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".
),
) );
}
+
+add_action( 'cmb2_admin_init', 'wpfc_sermon_metaboxes' );
+
+/**
+ * Gets a number of terms and displays them as options
+ *
+ * @param string $taxonomy Taxonomy terms to retrieve. Default is category.
+ *
+ * @return array An array of options that matches the CMB2 options array
+ */
+function cmb2_get_term_options( $taxonomy = 'category' ) {
+ $args['taxonomy'] = $taxonomy;
+ $taxonomy = $args['taxonomy'];
+
+ $args = array(
+ 'hide_empty' => false,
+ );
+
+ $terms = (array) get_terms( $taxonomy, $args );
+
+ // Initialize an empty array.
+ $term_options = array();
+ if ( ! empty( $terms ) ) {
+ foreach ( $terms as $term ) {
+ $term_options[ $term->term_id ] = $term->name;
+ }
+ }
+
+ return $term_options;
+}
+
+/**
+ * Sanitizes the number.
+ *
+ * @param null $null Unused.
+ * @param string|integer $value Value to sanitize.
+ *
+ * @return null|string|string[]
+ */
+function sm_cmb2_sanitize_text_number( $null = null, $value = '' ) {
+ $value = preg_replace( '/[^0-9]/', '', $value );
+
+ return $value;
+}
+
+add_filter( 'cmb2_sanitize_text_number', 'sm_cmb2_sanitize_text_number', 10, 2 );
diff --git a/includes/admin/sm-meta-box-functions.php b/includes/admin/sm-meta-box-functions.php
deleted file mode 100644
index e346550..0000000
--- a/includes/admin/sm-meta-box-functions.php
+++ /dev/null
@@ -1,253 +0,0 @@
-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 '
- ' . 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 '
';
-}
-
-/**
- * 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 '
- ' . 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 '
';
-}
-
-/**
- * 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 '
- ' . 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 '
';
-}
-
-/**
- * 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 '
- ' . wp_kses_post( $field['label'] ) . ' ';
-
- if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) {
- //echo sm_help_tip( $field['description'] );
- }
-
- echo '';
-
- foreach ( $field['options'] as $key => $value ) {
- echo '' . esc_html( $value ) . ' ';
- }
-
- 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
index 97be4ab..458c584 100644
--- a/includes/admin/views/html-admin-import-export.php
+++ b/includes/admin/views/html-admin-import-export.php
@@ -1,170 +1,199 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Plugin not installed
+
+
+
+
+
+
+
+
+
+
+
+
+
+ here' );
+ ?>
+
+
+
+
+
+
Plugin not installed
+
+
+
+
+
+
+
+
+
+
+
+
+
+ here' );
+ ?>
+
+
+
+
+
+
+
+
+
+
diff --git a/includes/class-sm-api.php b/includes/class-sm-api.php
index 65d7066..13e66da 100644
--- a/includes/class-sm-api.php
+++ b/includes/class-sm-api.php
@@ -1,8 +1,14 @@
ID, 'sermon_date', strtotime( $post->post_date ) );
+ update_post_meta( $post->ID, 'sermon_date_auto', 1 );
+ } else {
+ continue;
+ }
}
update_post_meta( $post->ID, $key, $data );
- if ( $key === 'sermon_date' ) {
- update_post_meta( $post->ID, 'sermon_date_auto', $data === '' );
+ if ( 'sermon_date' === $key ) {
+ update_post_meta( $post->ID, 'sermon_date_auto', 0 );
}
add_filter( "cmb2_override_{$key}_meta_remove", '__return_true' );
@@ -67,20 +80,20 @@ public function save_custom_data( $post, $request ) {
}
/**
- * Fixes ordering by date to use `sermon_date` meta (aka "Preached Date")
- * Use "wpdate" for original WordPress "date" ordering
+ * Fixes ordering by date to use `sermon_date` meta (aka "Preached Date").
+ * Use "wpdate" for original WordPress "date" ordering.
*
- * @param array $args WP_Query arguments
+ * @param array $args Query parameters.
*
* @return mixed Modified arguments
*/
public function fix_ordering( $args ) {
- if ( $args['orderby'] === 'date' ) {
+ if ( 'date' === $args['orderby'] ) {
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = 'sermon_date';
$args['meta_value_num'] = time();
$args['meta_compare'] = '<=';
- } elseif ( $args['orderby'] === 'wpdate' ) {
+ } elseif ( 'wpdate' === $args['orderby'] ) {
$args['orderby'] = 'date';
}
@@ -88,14 +101,14 @@ public function fix_ordering( $args ) {
}
/**
- * Currently, it only replaces "post" string with "sermon", but we can add more query parameters here if needed
+ * Currently, it only replaces "post" string with "sermon", but we can add more query parameters here if needed.
*
- * @param array $query_params
+ * @param array $query_params Query parameters.
*
* @return array Modified query params
*/
public function modify_query_params( $query_params ) {
- // Replace "post" to "sermon"
+ // Replace "post" to "sermon".
$query_params['slug']['description'] = str_replace( 'post', 'sermon', $query_params['slug']['description'] );
$query_params['status']['description'] = str_replace( 'post', 'sermon', $query_params['status']['description'] );
$query_params['after']['description'] = str_replace( 'post', 'sermon', $query_params['after']['description'] );
@@ -105,11 +118,11 @@ public function modify_query_params( $query_params ) {
}
/**
- * Add custom data to the response, such as audio, passage, etc
+ * Add custom data to the response, such as audio, passage, etc.
*
* @param WP_REST_Response $response The response object.
*
- * @return WP_REST_Response Modified response
+ * @return WP_REST_Response Modified response,
*/
public function add_custom_data( $response ) {
$data = &$response->data;
@@ -127,7 +140,7 @@ public function add_custom_data( $response ) {
'sermon_date_auto' => array( '' ),
) );
- $data['sermon_audio'] = $post_meta['sermon_audio'][0];
+ $data['sermon_audio'] = isset( $post_meta['sermon_audio_id'][0] ) ? wp_get_attachment_url( intval( $post_meta['sermon_audio_id'][0] ) ) : $post_meta['sermon_audio'][0];
$data['sermon_audio_duration'] = $post_meta['_wpfc_sermon_duration'][0];
$data['_views'] = $post_meta['Views'][0];
$data['bible_passage'] = $post_meta['bible_passage'][0];
@@ -137,13 +150,14 @@ public function add_custom_data( $response ) {
$data['sermon_bulletin'] = $post_meta['sermon_bulletin'][0];
$data['_featured_url'] = wp_get_attachment_url( $post_meta['_thumbnail_id'][0] );
- if ( $date = SM_Dates::get( 'U', $data['id'] ) ) {
+ $date = SM_Dates::get( 'U', $data['id'] );
+ if ( $date ) {
$data['sermon_date'] = intval( $date );
- $data['_sermon_date_auto'] = $post_meta['sermon_date_auto'][0] == 1 ? true : false;
+ $data['_sermon_date_auto'] = 1 == $post_meta['sermon_date_auto'][0] ? true : false;
}
return $response;
}
}
-new SM_API();
\ No newline at end of file
+new SM_API();
diff --git a/includes/class-sm-autoloader.php b/includes/class-sm-autoloader.php
index f1b1892..e289f9e 100644
--- a/includes/class-sm-autoloader.php
+++ b/includes/class-sm-autoloader.php
@@ -1,4 +1,10 @@
'wpfc_sermon_series',
- 'hide_empty' => false,
+ 'taxonomy' => array(
+ 'wpfc_sermon_series',
+ 'wpfc_preacher',
+ 'wpfc_sermon_topics',
+ 'wpfc_bible_book',
+ 'wpfc_service_type',
+ ),
+ 'hide_empty' => true,
) ) as $term
) {
$term_meta = get_term_meta( $term->term_id );
@@ -129,11 +152,11 @@ public static function update_series_date() {
'orderby' => 'meta_value_num',
'tax_query' => array(
array(
- 'taxonomy' => 'wpfc_sermon_series',
+ 'taxonomy' => $term->taxonomy,
'field' => 'term_id',
- 'terms' => $term->term_id
- )
- )
+ 'terms' => $term->term_id,
+ ),
+ ),
) );
if ( $query->have_posts() ) {
$date = get_post_meta( $query->posts[0]->ID, 'sermon_date', true );
@@ -148,7 +171,7 @@ public static function update_series_date() {
}
/**
- * Used to save date that was there before sermon update, for later comparison
+ * Used to save date that was there before sermon update, for later comparison.
*
* @param int $post_ID Post ID.
*
@@ -163,7 +186,7 @@ public static function get_original_date( $post_ID ) {
}
/**
- * Sets/updates date for posts if they are not user-defined
+ * Sets/updates date for posts if they are not user-defined.
*
* @param int $post_ID Post ID.
* @param WP_Post $post Post object.
@@ -172,10 +195,11 @@ public static function get_original_date( $post_ID ) {
* @since 2.7
*/
public static function maybe_update_date( $post_ID, $post, $update ) {
- $update_date = $auto = false;
+ $update_date = false;
+ $auto = false;
if ( $update ) {
- // compare sermon date and if user changed it update sermon date and disable auto update
+ // Compare sermon date and if user changed it update sermon date and disable auto update.
if ( ! empty( $_POST['sermon_date'] ) ) {
switch ( \SermonManager::getOption( 'date_format' ) ) {
case '0':
@@ -201,10 +225,10 @@ public static function maybe_update_date( $post_ID, $post, $update ) {
$time = array(
$dt_post->format( 'H' ),
$dt_post->format( 'i' ),
- $dt_post->format( 's' )
+ $dt_post->format( 's' ),
);
- // convert all to ints
+ // Convert all to ints.
$time = array_map( 'intval', $time );
list( $hours, $minutes, $seconds ) = $time;
@@ -217,30 +241,31 @@ public static function maybe_update_date( $post_ID, $post, $update ) {
}
}
- // compare published date and if user changed it update sermon date if auto update is set
+ // Compare published date and if user changed it update sermon date if auto update is set.
if ( ! empty( $GLOBALS['sm_original_published_date'] ) ) {
- if ( $post->post_date !== $GLOBALS['sm_original_published_date'] &&
- get_post_meta( $post_ID, 'sermon_date_auto', true ) == 1 ) {
+ if ( $post->post_date !== $GLOBALS['sm_original_published_date'] && 1 == get_post_meta( $post_ID, 'sermon_date_auto', true ) ) {
$update_date = true;
}
}
}
- // if sermon date is blank (not set on sermon create or removed later on update), mark
- // this post for auto updating and update date now
- if ( isset( $_POST['sermon_date'] ) && $_POST['sermon_date'] == '' ) {
+ /*
+ * If sermon date is blank (not set on sermon create or removed later on update), mark
+ * this post for auto updating and update date now.
+ */
+ if ( isset( $_POST['sermon_date'] ) && '' == $_POST['sermon_date'] ) {
$update_date = true;
$auto = true;
}
- // if marked for date updating
+ // If marked for date updating.
if ( $update_date ) {
update_post_meta( $post_ID, 'sermon_date', mysql2date( 'U', $post->post_date ) );
}
- // if we should set it for auto date updating
+ // If we should set it for auto date updating.
if ( $auto ) {
update_post_meta( $post_ID, 'sermon_date_auto', '1' );
}
}
-}
\ No newline at end of file
+}
diff --git a/includes/class-sm-dates.php b/includes/class-sm-dates.php
index ef8d63a..a88f187 100644
--- a/includes/class-sm-dates.php
+++ b/includes/class-sm-dates.php
@@ -1,10 +1,16 @@
) Sermon Manager versions will save
- * the date as Unix timestamp so sanitation is not required
+ * the date as Unix timestamp so sanitation is not required.
*
- * @return string|false Date when sermon was preached. False on failure
+ * @return string|false Date when sermon was preached. False on failure.
*/
public static function get( $format = '', $post = null, $force_unix_sanitation = false ) {
- // Reset the variable
- $has_time = $sanitized = false;
+ // Reset the variable.
+ $has_time = false;
+ $sanitized = false;
- // Get the sermon
+ // Get the sermon.
$post = get_post( $post );
- // If we are working on right post type
- if ( ! $post || $post->post_type !== 'wpfc_sermon' ) {
+ // If we are working on right post type.
+ if ( ! $post || 'wpfc_sermon' !== $post->post_type ) {
return false;
}
- // Check if date is set
- if ( ! $date = get_post_meta( $post->ID, 'sermon_date', true ) ) {
+ // Check if date is set.
+ $date = get_post_meta( $post->ID, 'sermon_date', true );
+ if ( ! $date ) {
return false;
}
- // Save original date to a variable to allow later filtering
+ // Save original date to a variable to allow later filtering.
$orig_date = $date;
- // 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 it's already an Unix timestamp, don't convert it.
+ $date_copy = intval( trim( $date ) );
+ if ( is_numeric( $date ) && $date_copy ) {
+ $dt = DateTime::createFromFormat( 'U', $date_copy );
if ( $dt->format( 'H' ) !== '00' || $dt->format( 'i' ) !== '00' ) {
$has_time = true;
}
@@ -57,8 +66,8 @@ public static function get( $format = '', $post = null, $force_unix_sanitation =
update_post_meta( $post->ID, 'sermon_date', $date );
}
- // Check if we need to force it
- if ( $sanitized === false && $force_unix_sanitation === true ) {
+ // Check if we need to force it.
+ if ( false === $sanitized && true === $force_unix_sanitation ) {
$date = self::sanitize( $date );
}
@@ -70,10 +79,10 @@ public static function get( $format = '', $post = null, $force_unix_sanitation =
$time = array(
$dt->format( 'H' ),
$dt->format( 'i' ),
- $dt->format( 's' )
+ $dt->format( 's' ),
);
- // convert all to ints
+ // Convert all to ints.
$time = array_map( 'intval', $time );
list( $hours, $minutes, $seconds ) = $time;
@@ -81,13 +90,15 @@ public static function get( $format = '', $post = null, $force_unix_sanitation =
$date += $hours * HOUR_IN_SECONDS + $minutes * MINUTE_IN_SECONDS + $seconds;
}
- // Check if format is set. If not, set to WP defined, or in super rare cases
- // when WP format is not defined, set it to Unix timestamp
+ /*
+ * Check if format is set. If not, set to WP defined, or in super rare cases
+ * when WP format is not defined, set it to Unix timestamp.
+ */
if ( empty( $format ) ) {
$format = get_option( 'date_format', 'U' );
}
- // Format it
+ // Format it.
$date = date_i18n( $format, $date );
/**
@@ -106,7 +117,7 @@ public static function get( $format = '', $post = null, $force_unix_sanitation =
/**
* Tries to convert the textual date to Unix timestamp
*
- * @param string $date
+ * @param string $date The textual representation of date.
*
* @return int Unix timestamp
*/
@@ -126,8 +137,4 @@ protected static function sanitize( $date ) {
*/
return apply_filters( 'sm_sanitize_date', $sanitized_date, $date );
}
-
- public static function set( $date, $post ) {
-
- }
-}
\ No newline at end of file
+}
diff --git a/includes/class-sm-install.php b/includes/class-sm-install.php
index 4ca3f89..44f6844 100644
--- a/includes/class-sm-install.php
+++ b/includes/class-sm-install.php
@@ -1,5 +1,11 @@
array(
'sm_update_28_revert_old_dates',
@@ -17,7 +27,7 @@ class SM_Install {
'sm_update_28_save_sermon_render_into_post_content',
),
'2.8.4' => array(
- 'sm_update_284_resave_sermons'
+ 'sm_update_284_resave_sermons',
),
'2.9' => array(
'sm_update_29_fill_out_series_dates',
@@ -27,20 +37,31 @@ class SM_Install {
'sm_update_293_fix_import_dates',
),
'2.10' => array(
- 'sm_update_210_update_options'
+ 'sm_update_210_update_options',
),
'2.11' => array(
'sm_update_211_render_content',
'sm_update_211_update_date_time',
),
'2.12.3' => array(
- 'sm_update_2123_fix_preacher_permalink'
- )
+ 'sm_update_2123_fix_preacher_permalink',
+ ),
+ '2.13.0' => array(
+ 'sm_update_2130_fill_out_sermon_term_dates',
+ 'sm_update_2130_remove_excerpts',
+ ),
);
- /** @var object Background update class */
+ /**
+ * Background update class
+ *
+ * @var object
+ */
private static $background_updater;
+ /**
+ * Initialize the updater.
+ */
public static function init() {
add_action( 'init', array( __CLASS__, 'init_background_updater' ), 3 );
add_action( 'init', array( __CLASS__, 'check_version' ), 8 );
@@ -50,21 +71,21 @@ public static function init() {
}
/**
- * Check Sermon Manager version and run the updater is required
+ * Check Sermon Manager version and run the updater is required.
*
- * This check is done on all requests and runs if the versions do not match
+ * This check is done on all requests and runs if the versions do not match.
*/
public static function check_version() {
global $pagenow;
- if ( ! defined( 'IFRAME_REQUEST' ) && ( ( $pagenow === 'plugins.php' && isset( $_GET['activate'] ) && $_GET['activate'] === 'true' ) || get_option( 'sm_version' ) !== SM_VERSION ) ) {
+ if ( ! defined( 'IFRAME_REQUEST' ) && ( ( 'plugins.php' === $pagenow && isset( $_GET['activate'] ) && 'true' === $_GET['activate'] ) || SM_VERSION !== get_option( 'sm_version' ) ) ) {
self::_install();
do_action( 'sm_updated' );
}
}
/**
- * Install Sermon Manager
+ * Install Sermon Manager.
*/
private static function _install() {
global $wpdb;
@@ -77,23 +98,23 @@ private static function _install() {
define( 'SM_INSTALLING', true );
}
+ // self::_create_roles(); @todo: will be done in future versions (move it below options).
self::_create_options();
- //self::_create_roles(); todo: will be done in future versions
- // Register post types
+ // Register post types.
SM_Post_types::register_post_types();
SM_Post_types::register_taxonomies();
- // do update
+ // Do update.
self::_update();
- // Update version just in case
+ // Update version just in case.
self::update_db_version();
- // Flush 1
+ // Flush 1.
do_action( 'sm_flush_rewrite_rules' );
- // Flush 2
+ // Flush 2.
add_action( 'init', function () {
do_action( 'sm_flush_rewrite_rules' );
} );
@@ -105,15 +126,13 @@ private static function _install() {
*
* Based on code inside core's upgrade_network() function.
*/
- /** @noinspection SqlNoDataSourceInspection */
- $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
+ $wpdb->query( $wpdb->prepare( "DELETE a, b FROM $wpdb->options a, $wpdb->options b
WHERE a.option_name LIKE %s
AND a.option_name NOT LIKE %s
AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
- AND b.option_value < %d";
- $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', time() ) );
+ AND b.option_value < %d", $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', time() ) );
- // Trigger action
+ // Trigger action.
do_action( 'sm_installed' );
}
@@ -125,7 +144,7 @@ private static function _install() {
* @since 2.10
*/
private static function _create_options() {
- // Include settings so that we can run through defaults
+ // Include settings so that we can run through defaults.
include_once 'admin/class-sm-admin-settings.php';
$settings = SM_Admin_Settings::get_settings_pages();
@@ -180,7 +199,7 @@ private static function _get_db_update_callbacks() {
/**
* Update DB version to current.
*
- * @param string $version (optional)
+ * @param string $version (optional).
*/
public static function update_db_version( $version = null ) {
delete_option( 'sm_version' );
@@ -188,7 +207,7 @@ public static function update_db_version( $version = null ) {
}
/**
- * Init background updates
+ * Init background updates.
*/
public static function init_background_updater() {
include_once 'class-sm-background-updater.php';
@@ -196,9 +215,9 @@ public static function init_background_updater() {
}
/**
- * Add more cron schedules
+ * Add more cron schedules.
*
- * @param array $schedules
+ * @param array $schedules The existing array of schedule data.
*
* @return array
*/
@@ -214,7 +233,7 @@ public static function cron_schedules( $schedules ) {
/**
* Show action links on the plugin screen.
*
- * @param mixed $links Plugin Action links
+ * @param mixed $links Plugin Action links.
*
* @return array
*/
@@ -229,13 +248,12 @@ public static function plugin_action_links( $links ) {
/**
* Show row meta on the plugin screen.
*
- * @param mixed $links Plugin Row Meta
- * @param mixed $file Plugin Base file
+ * @param mixed $links Plugin Row Meta.
+ * @param mixed $file Plugin Base file.
*
* @return array
*/
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' ) . ' ',
diff --git a/includes/class-sm-post-types.php b/includes/class-sm-post-types.php
index 1450c16..f0db1de 100644
--- a/includes/class-sm-post-types.php
+++ b/includes/class-sm-post-types.php
@@ -1,14 +1,20 @@
'manage_wpfc_categories',
+ 'edit_terms' => 'manage_wpfc_categories',
+ 'delete_terms' => 'manage_wpfc_categories',
+ 'assign_terms' => 'manage_wpfc_categories'
+ );
register_taxonomy( 'wpfc_preacher',
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' => wp_sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ),
+ 'label' => ucwords( $preacher_label ),
'labels' => array(
- /* 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) */
+ 'name' => ucwords( $preacher_label_plural ),
+ 'singular_name' => ucwords( $preacher_label ),
+ 'menu_name' => ucwords( $preacher_label_plural ),
+ /* translators: Preachers */
+ 'search_items' => wp_sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), $preacher_label_plural ),
+ /* translators: Preachers */
+ 'all_items' => wp_sprintf( __( 'All %s', 'sermon-manager-for-wordpress' ), $preacher_label_plural ),
+ 'parent_item' => null,
+ 'parent_item_colon' => null,
+ /* translators: Preachers */
'edit_item' => wp_sprintf( __( 'Edit %s', 'sermon-manager-for-wordpress' ), $preacher_label ),
- /* translators: %s Preacher label (lowercase; singular) */
+ /* translators: Preachers */
'update_item' => wp_sprintf( __( 'Update %s', 'sermon-manager-for-wordpress' ), $preacher_label ),
- /* translators: %s Preacher label (lowercase; singular) */
+ /* translators: Preachers */
'add_new_item' => wp_sprintf( __( 'Add new %s', 'sermon-manager-for-wordpress' ), $preacher_label ),
- /* translators: %s Preacher label (lowercase; singular) */
+ /* translators: Preachers */
'new_item_name' => wp_sprintf( __( 'New %s name', 'sermon-manager-for-wordpress' ), $preacher_label ),
- /* translators: %s Preacher label (lowercase; singular) */
+ /* translators: Preachers */
'not_found' => wp_sprintf( __( 'No %s found', 'sermon-manager-for-wordpress' ), $preacher_label ),
),
'show_ui' => true,
'query_var' => true,
'show_in_rest' => true,
- 'rewrite' => array( 'slug' => $permalinks['wpfc_preacher'], 'with_front' => false ),
- ) ) );
+ 'rewrite' => array(
+ 'slug' => $permalinks['wpfc_preacher'],
+ 'with_front' => false,
+ ),
+ 'capabilities' => $capabilities,
+ ) )
+ );
register_taxonomy( 'wpfc_sermon_series',
apply_filters( 'sm_taxonomy_objects_wpfc_sermon_series', array( 'wpfc_sermon' ) ),
@@ -83,8 +98,8 @@ public static function register_taxonomies() {
'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
- 'parent_item_colon' => null, // it's not hierarchical
+ 'parent_item' => null,
+ 'parent_item_colon' => null,
'edit_item' => __( 'Edit series', 'sermon-manager-for-wordpress' ),
'update_item' => __( 'Update series', 'sermon-manager-for-wordpress' ),
'add_new_item' => __( 'Add new series', 'sermon-manager-for-wordpress' ),
@@ -94,8 +109,13 @@ public static function register_taxonomies() {
'show_ui' => true,
'query_var' => true,
'show_in_rest' => true,
- 'rewrite' => array( 'slug' => $permalinks['wpfc_sermon_series'], 'with_front' => false ),
- ) ) );
+ 'rewrite' => array(
+ 'slug' => $permalinks['wpfc_sermon_series'],
+ 'with_front' => false,
+ ),
+ 'capabilities' => $capabilities,
+ ) )
+ );
register_taxonomy( 'wpfc_sermon_topics',
apply_filters( 'sm_taxonomy_objects_wpfc_sermon_topics', array( 'wpfc_sermon' ) ),
@@ -119,8 +139,13 @@ public static function register_taxonomies() {
'show_ui' => true,
'query_var' => true,
'show_in_rest' => true,
- 'rewrite' => array( 'slug' => $permalinks['wpfc_sermon_topics'], 'with_front' => false ),
- ) ) );
+ 'rewrite' => array(
+ 'slug' => $permalinks['wpfc_sermon_topics'],
+ 'with_front' => false,
+ ),
+ 'capabilities' => $capabilities,
+ ) )
+ );
register_taxonomy( 'wpfc_bible_book',
apply_filters( 'sm_taxonomy_objects_wpfc_bible_book', array( 'wpfc_sermon' ) ),
@@ -144,8 +169,13 @@ public static function register_taxonomies() {
'show_ui' => true,
'query_var' => true,
'show_in_rest' => true,
- 'rewrite' => array( 'slug' => $permalinks['wpfc_bible_book'], 'with_front' => false ),
- ) ) );
+ 'rewrite' => array(
+ 'slug' => $permalinks['wpfc_bible_book'],
+ 'with_front' => false,
+ ),
+ 'capabilities' => $capabilities,
+ ) )
+ );
register_taxonomy( 'wpfc_service_type',
apply_filters( 'sm_taxonomy_objects_wpfc_service_type', array( 'wpfc_sermon' ) ),
@@ -169,8 +199,13 @@ public static function register_taxonomies() {
'show_ui' => true,
'query_var' => true,
'show_in_rest' => true,
- 'rewrite' => array( 'slug' => $permalinks['wpfc_service_type'], 'with_front' => false ),
- ) ) );
+ 'rewrite' => array(
+ 'slug' => $permalinks['wpfc_service_type'],
+ 'with_front' => false,
+ ),
+ 'capabilities' => $capabilities,
+ ) )
+ );
do_action( 'sm_after_register_taxonomy' );
}
@@ -191,7 +226,7 @@ public static function register_post_types() {
'labels' => array(
'name' => __( 'Sermons', 'sermon-manager-for-wordpress' ),
'singular_name' => __( 'Sermon', 'sermon-manager-for-wordpress' ),
- 'all_items' => __( 'All Sermons', 'sermon-manager-for-wordpress' ),
+ 'all_items' => __( 'Sermons', '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' ),
@@ -215,14 +250,21 @@ public static function register_post_types() {
),
'public' => true,
'show_ui' => true,
- 'capability_type' => 'post',
+ 'capability_type' => 'wpfc_sermon',
+ 'capabilities' => array(
+ 'manage_wpfc_categories' => 'manage_wpfc_categories',
+ 'manage_wpfc_sm_settings' => 'manage_wpfc_sm_settings'
+ ),
'map_meta_cap' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_in_menu' => true,
'menu_icon' => 'dashicons-sermon-manager',
'hierarchical' => false,
- 'rewrite' => array( 'slug' => $permalinks['wpfc_sermon'], 'with_front' => false ),
+ 'rewrite' => array(
+ 'slug' => $permalinks['wpfc_sermon'],
+ 'with_front' => false,
+ ),
'query_var' => true,
'show_in_nav_menus' => true,
'show_in_rest' => true,
@@ -235,7 +277,9 @@ public static function register_post_types() {
'comments',
'entry-views',
'elementor',
- )
+ ( ! \SermonManager::getOption( 'post_excerpt_enabled', 1 ) ? 'excerpt' : null ),
+ 'revisions',
+ ),
) ) );
do_action( 'sm_after_register_post_type' );
@@ -253,6 +297,7 @@ public static function flush_rewrite_rules() {
*/
public static function support_jetpack_omnisearch() {
if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) {
+ /* @noinspection PhpUndefinedClassInspection */
new Jetpack_Omnisearch_Posts( 'wpfc_sermon' );
}
}
@@ -260,7 +305,7 @@ public static function support_jetpack_omnisearch() {
/**
* Add sermon support for Jetpack related posts.
*
- * @param array $post_types
+ * @param array $post_types Array of allowed post types.
*
* @return array
*/
@@ -271,7 +316,7 @@ public static function rest_api_allowed_post_types( $post_types ) {
}
/**
- * Shorthand function for flush_rewrite_rules(true)
+ * Shorthand function for flush_rewrite_rules(true).
*
* @since 2.7.1
*/
diff --git a/includes/class-sm-roles.php b/includes/class-sm-roles.php
new file mode 100644
index 0000000..4d3ff83
--- /dev/null
+++ b/includes/class-sm-roles.php
@@ -0,0 +1,56 @@
+add_cap( 'read_wpfc_sermon' );
+ // Edit sermons.
+ $role->add_cap( 'edit_wpfc_sermon' );
+ $role->add_cap( 'edit_wpfc_sermons' );
+ $role->add_cap( 'edit_private_wpfc_sermons' );
+ $role->add_cap( 'edit_published_wpfc_sermons' );
+ // Delete sermons.
+ $role->add_cap( 'delete_wpfc_sermon' );
+ $role->add_cap( 'delete_wpfc_sermons' );
+ $role->add_cap( 'delete_published_wpfc_sermons' );
+ $role->add_cap( 'delete_private_wpfc_sermons' );
+ // Publish sermons.
+ $role->add_cap( 'publish_wpfc_sermons' );
+ // Read private sermons.
+ $role->add_cap( 'read_private_wpfc_sermons' );
+ // Manage categories & tags.
+ $role->add_cap( 'manage_wpfc_categories' );
+ // Add additional roles for administrator
+ if ( 'administrator' === $role_name ) {
+ // Access to Sermon Manager Settings.
+ $role->add_cap( 'manage_wpfc_sm_settings' );
+ }
+ // Add additional roles for administrator and editor
+ if ( 'author' !== $role_name ) {
+ $role->add_cap( 'edit_others_wpfc_sermons' );
+ $role->add_cap( 'delete_others_wpfc_sermons' );
+ }
+ }
+ }
+}
+
+SM_Roles::init();
diff --git a/includes/shortcodes.php b/includes/class-sm-shortcodes.php
similarity index 66%
rename from includes/shortcodes.php
rename to includes/class-sm-shortcodes.php
index 0fa2256..92fb416 100755
--- a/includes/shortcodes.php
+++ b/includes/class-sm-shortcodes.php
@@ -1,921 +1,940 @@
-legacyShortcodes();
- }
-
- /**
- * Get new instance self or current one if exists
- *
- * @return WPFC_Shortcodes
- */
- public static function getInstance() {
- if ( null === self::$instance ) {
- self::$instance = new self;
- }
-
- return self::$instance;
- }
-
- /**
- * They are here for compatibility purposes
- */
- public function legacyShortcodes() {
- add_shortcode( 'list-sermons', array( self::getInstance(), 'displaySermonsList' ) );
- add_shortcode( 'sermon-images', array( self::getInstance(), 'displayImages' ) );
- }
-
- /**
- * Display an unordered list of series, preachers, topics or books
- *
- * @param array[] $atts Shortcode parameters
- *
- * @type string $atts ['display'] The taxonomy, possible options: series, preachers, topics, books
- * @type string $atts ['order'] Sorting order, possible options: ASC, DESC
- * @type string $atts ['ordrerby'] Possible options: id, count, name, slug, term_group, none
- *
- * @return string List or error message.
- */
- public function displaySermonsList( $atts ) {
- // enqueue scripts and styles
- if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
- define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
- }
-
- // unquote
- if ( is_array( $atts ) || is_object( $atts ) ) {
- foreach ( $atts as &$att ) {
- $att = $this->_unquote( $att );
- }
- }
-
- // default options
- $args = array(
- 'display' => 'series',
- 'order' => 'ASC',
- 'orderby' => 'name',
- );
-
- // for compatibility
- if ( ! empty( $atts['tax'] ) ) {
- $atts['display'] = $atts['tax'];
- unset( $atts['tax'] );
- }
-
- // for compatibility
- if ( ! empty( $atts['taxonomy'] ) ) {
- $atts['display'] = $atts['taxonomy'];
- unset( $atts['taxonomy'] );
- }
-
- // join default and user options
- $args = shortcode_atts( $args, $atts, 'list_sermons' );
-
- // check if we are using a SM taxonomy, and if we are, convert to valid taxonomy name
- if ( $this->convertTaxonomyName( $args['display'], true ) ) {
- $args['display'] = $this->convertTaxonomyName( $args['display'], false );
- } else if ( ! $this->convertTaxonomyName( $args['display'], false ) ) {
- return 'Error: Invalid "list" parameter. Possible values are: "series", "preachers", "topics" and "books". You entered: "' . $args['display'] . ' "';
- }
-
- $query_args = array(
- 'taxonomy' => $args['display'],
- 'orderby' => $args['orderby'],
- 'order' => $args['order'],
- );
-
- 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();
- }
-
- // get items
- $terms = get_terms( $query_args );
-
- if ( count( $terms ) > 0 ) {
- // sort books by order
- if ( $args['display'] === 'wpfc_bible_book' && $args['orderby'] === '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;
- }
-
- $list = '';
-
- return $list;
- } else {
- // if nothing has been found
- return 'No ' . $this->convertTaxonomyName( $args['display'], true ) . ' found.';
- }
- }
-
- /**
- * 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.
- *
- * @param string $name
- * @param bool $new_name Should it return user friendly name
- *
- * @return string|null null if nothing found, name otherwise
- */
- public function convertTaxonomyName( $name, $new_name ) {
- $old_taxonomies = array(
- 'wpfc_sermon_series',
- 'wpfc_preacher',
- 'wpfc_sermon_topics',
- 'wpfc_bible_book',
- 'wpfc_service_type'
- );
- $new_taxonomies = array( 'series', 'preachers', 'topics', 'books', 'service_types' );
-
- if ( $new_name ) {
- if ( in_array( $name, $old_taxonomies ) ) {
- return $new_taxonomies[ array_search( $name, $old_taxonomies ) ];
- }
-
- // return itself if it's already converted. try plural if (assumed) singular doesn't exist
- foreach ( array( $name, $name . 's' ) as $name_s ) {
- if ( in_array( $name_s, $new_taxonomies ) ) {
- return $name_s;
- }
- }
- } else {
- // try plural if (assumed) singular doesn't exist
- foreach ( array( $name, $name . 's' ) as $name_s ) {
- if ( in_array( $name_s, $new_taxonomies ) ) {
- return $old_taxonomies[ array_search( $name_s, $new_taxonomies ) ];
- }
- }
-
- // return itself if it's already converted
- if ( in_array( $name, $old_taxonomies ) ) {
- return $name;
- }
- }
-
- return null;
- }
-
- /**
- * Display all series or speakers in a grid of images
- *
- * @param array $atts Shortcode parameters
- *
- * @type string $atts ['display'] The taxonomy, possible options: series, preachers
- * @type string $atts ['order'] Sorting order, possible options: ASC, DESC
- * @type string $atts ['ordrerby'] Possible options: id, count, name, slug, term_group, none
- * @type string $atts ['size'] Possible options: sermon_small, sermon_medium, sermon_wide, thumbnail, medium,
- * large, full, or any size added with add_image_size()
- * @type bool $atts ['hide_title'] Should we hide title, default false
- * @type bool $atts ['show_description'] Should we show the description, default false
- *
- * @return string Grid or error message.
- */
- public function displayImages( $atts = array() ) {
- // enqueue scripts and styles
- if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
- define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
- }
-
- // unquote
- if ( is_array( $atts ) || is_object( $atts ) ) {
- foreach ( $atts as &$att ) {
- $att = $this->_unquote( $att );
- }
- }
-
- // default args
- $args = array(
- 'display' => 'series',
- 'order' => 'DESC',
- 'orderby' => 'name',
- 'size' => 'sermon_medium',
- 'hide_title' => false,
- 'show_description' => false,
- );
-
- // for compatibility
- if ( ! empty( $atts['tax'] ) ) {
- $atts['display'] = $atts['tax'];
- unset( $atts['tax'] );
- }
-
- // for compatibility
- if ( ! empty( $atts['show_desc'] ) ) {
- $atts['show_description'] = $atts['show_desc'];
- unset( $atts['show_desc'] );
- }
-
- // join default and user options
- $args = shortcode_atts( $args, $atts, 'sermon_images' );
-
- // convert to bool
- $args['show_description'] = (bool) $args['show_description'];
-
- // check if we are using a SM taxonomy, and if we are, convert to valid taxonomy name
- if ( $this->convertTaxonomyName( $args['display'], true ) ) {
- $args['display'] = $this->convertTaxonomyName( $args['display'], false );
- } else if ( ! $this->convertTaxonomyName( $args['display'], false ) ) {
- return 'Error: Invalid "list" parameter. Possible values are: "series", "preachers", "topics" and "books". You entered: "' . $args['display'] . ' "';
- }
-
- // get images
- $terms = apply_filters( 'sermon-images-get-terms', '', array(
- 'taxonomy' => $args['display'],
- 'term_args' => array(
- 'order' => $args['order'],
- 'orderby' => $args['orderby'],
- )
- ) );
-
- // $terms will always return an array
- if ( ! empty( $terms ) ) {
- $list = '';
-
- return $list;
- } else {
- // if nothing has been found
- return 'No ' . $this->convertTaxonomyName( $args['display'], true ) . ' images found.';
- }
- }
-
- /**
- * Display the latest sermon series image (optional - by service type)
- *
- * @param array $atts Shortcode options
- *
- * @type string $atts ['image_class'] CSS class for image
- * @type string $atts ['size'] Image size. Possible options: sermon_small, sermon_medium, sermon_wide, thumbnail,
- * medium, large, full, or any size added with add_image_size()
- * @type bool $atts ['show_title'] false to hide the series title (true is the default)
- * @type string $atts ['title_wrapper'] Possible options: p, h1, h2, h3, h4, h5, h6, div
- * @type string $atts ['title_class'] CSS class for title
- * @type string $atts ['service_type'] Service type ID/slug/name. Used to get latest series from that service type.
- * @type bool $atts ['show_description'] false to hide the series description (true is the default)
- * @type string $atts ['wrapper_class'] CSS class for wrapper
- *
- * @return string
- */
- function displayLatestSeriesImage( $atts = array() ) {
- // enqueue scripts and styles
- if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
- define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
- }
-
- // unquote
- if ( is_array( $atts ) || is_object( $atts ) ) {
- foreach ( $atts as &$att ) {
- $att = $this->_unquote( $att );
- }
- }
-
- // default options
- $args = array(
- 'image_class' => 'latest-series-image',
- 'size' => 'large',
- 'show_title' => 'yes',
- 'title_wrapper' => 'h3',
- 'title_class' => 'latest-series-title',
- 'service_type' => '',
- 'show_description' => 'yes',
- 'wrapper_class' => 'latest-series',
- );
-
- // for compatibility
- if ( ! empty( $atts['show_desc'] ) ) {
- $atts['show_description'] = $atts['show_desc'];
- unset( $atts['show_desc'] );
- }
-
- // join default and user options
- $args = shortcode_atts( $args, $atts, 'latest_series' );
-
- // get latest series
- $latest_series = $this->getLatestSeries( 0, $args['service_type'] );
-
- // if for some reason we couldn't get latest series
- if ( $latest_series === null ) {
- return 'No latest series found.';
- }
-
- // Image ID
- $series_image_id = $this->getLatestSeriesImageId( $latest_series );
-
- // if for some reason we couldn't get latest series image
- if ( $series_image_id === null ) {
- return 'No latest series image found.';
- }
-
- // link to series
- $series_link = get_term_link( $latest_series, 'wpfc_sermon_series' );
- // image CSS class
- $image_class = sanitize_html_class( $args['image_class'] );
- // title wrapper tag name
- $wrapper_options = array( 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div' );
- if ( ! in_array( sanitize_text_field( $args['title_wrapper'] ), $wrapper_options ) ) {
- $args['title_wrapper'] = 'h3';
- }
- // title CSS class
- $title_class = sanitize_html_class( $args['title_class'] );
-
- $link_open = '';
- $link_close = ' ';
-
- $image = wp_get_attachment_image( $series_image_id, $args['size'], false, array( 'class' => $image_class ) );
-
- $title = $description = '';
- if ( $args['show_title'] === 'yes' ) {
- $title = $latest_series->name;
- $title = '<' . $args['title_wrapper'] . ' class="' . $title_class . '">' . $title . '' . $args['title_wrapper'] . '>';
- }
- if ( $args['show_description'] === 'yes' ) {
- $description = '' . wpautop( $latest_series->description ) . '
';
- }
-
- $wrapper_class = sanitize_html_class( $args['wrapper_class'] );
- $before = '';
- $after = '
';
-
- $output = $before . $link_open . $image . $title . $link_close . $description . $after;
-
- return $output;
- }
-
- /**
- * Get all sermon series as WP_Term object
- *
- * @param int $latest_sermon Optional. Latest sermon ID. If not provided, it will try to get it automatically.
- * @param int $service_type Optional. Service Type for getting latest sermon ID
- *
- * @return WP_Term|null
- */
- public function getLatestSeries( $latest_sermon = 0, $service_type = 0 ) {
- if ( empty( $latest_sermon ) ) {
- $latest_sermon = $this->getLatestSermonId( $service_type );
- }
-
- $latest_series = get_the_terms( $latest_sermon, 'wpfc_sermon_series' );
-
- if ( is_array( $latest_series ) && ! empty( $latest_series ) ) {
- return $latest_series[0];
- }
-
- return null;
- }
-
- /**
- * Get the latest sermon ID
- *
- * @param string|int $service_type Optional argument to get latest sermon from specified service type. Slug, name
- * and ID are accepted values.
- *
- * @return int|null Sermon ID on success, null on failure
- */
- public function getLatestSermonId( $service_type = 0 ) {
- $args = array(
- 'post_type' => 'wpfc_sermon',
- 'posts_per_page' => 1,
- 'post_status' => 'publish',
- 'no_found_rows' => true,
- 'update_post_term_cache' => false,
- 'update_post_meta_cache' => false
- );
-
- // if service type is set
- if ( $service_type !== 0 ) {
- /*
- * if it's not numeric, we will try to find it by slug;
- * if not found by slug, we will try to find it by name.
- */
-
- if ( ! is_numeric( $service_type ) ) {
- foreach ( array( 'slug', 'name' ) as $field ) {
- $service_type = get_term_by( $field, $service_type, 'wpfc_service_type' );
-
- if ( $service_type !== false ) {
- $service_type = intval( $service_type->term_id );
- break;
- }
- }
- } else {
- // convert to int, if string number is used
- $service_type = intval( $service_type );
- }
-
- if ( is_int( $service_type ) && term_exists( $service_type, 'wpfc_service_type' ) ) {
- $args['tax_query'] = array(
- 'taxonomy' => 'wpfc_service_type',
- 'terms' => $service_type,
- );
- }
- }
-
- $latest_sermon = new WP_Query( $args );
-
- // if there is a post, return ID
- if ( ! empty( $latest_sermon->post_count ) ) {
- wp_reset_postdata();
-
- return $latest_sermon->post->ID;
- }
-
- return null;
- }
-
- /**
- * Get the image ID of the specified series ID
- * Will try to get image ID of latest series if $latest_series argument not set
- *
- * @param int $series Series to get the image of
- *
- * @return int|null
- */
- function getLatestSeriesImageId( $series = 0 ) {
- if ( $series === 0 ) {
- $series = $this->getLatestSeries();
-
- if ( $series === null ) {
- return null;
- }
- }
-
- $associations = sermon_image_plugin_get_associations();
- $tt_id = absint( $series->term_taxonomy_id );
-
- if ( array_key_exists( $tt_id, $associations ) ) {
- $ID = absint( $associations[ $tt_id ] );
-
- return $ID;
- }
-
- return null;
- }
-
- /**
- * Renders sorting HTML.
- *
- * @param array $atts Shortcode parameters.
- *
- * @type string $series_filter Do filtering in this specific series (slug)
- * @type string $series Force specific series to show. Slug only
- * @type string $preachers Force specific preacher to show. Slug only
- * @type string $topics Force specific topic to show. Slug only
- * @type string $books Force specific book to show. Slug only
- * @type string $visibility 'none' to hide the forced fields, 'disable' to show them as disabled and 'suggest' to
- * just set the default value while allowing user to change it. Default 'suggest'
- *
- * @return string Sorting HTML
- *
- * @since 2.5.0 added shortcode parameters
- */
- public function displaySermonSorting( $atts = array() ) {
- // enqueue scripts and styles
- if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
- define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
- }
-
- // unquote
- if ( is_array( $atts ) || is_object( $atts ) ) {
- foreach ( $atts as &$att ) {
- $att = $this->_unquote( $att );
- }
- }
-
- // default shortcode options
- $args = array(
- 'series_filter' => '',
- 'service_type_filter' => '',
- 'series' => '',
- 'preachers' => '',
- 'topics' => '',
- 'books' => '',
- 'visibility' => 'suggest',
- 'hide_topics' => '',
- 'hide_series' => '',
- 'hide_preachers' => '',
- 'hide_books' => '',
- 'hide_service_types' => 'yes',
- );
-
- // merge default and user options
- $args = shortcode_atts( $args, $atts, 'sermon_sort_fields' );
-
- return render_wpfc_sorting( $args );
- }
-
- /**
- * Main sermon display code
- *
- * @param array $atts Shortcode parameters
- *
- * @type int $atts ['per_page'] How many sermons per page.
- * @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 ['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
- * @type string $atts ['filter_value'] ID/slug of allowed filters
- * @type int $atts ['year'] 4 digit year (e.g. 2011)
- * @type int $atts ['month'] Month number (from 1 to 12)
- * @type int $atts ['week'] Week of the year (from 0 to 53)
- * @type int $atts ['day'] Day of the month (from 1 to 31)
- * @type string $atts ['after'] Date to retrieve posts after. Accepts strtotime()-compatible string
- * @type string $atts ['before'] Date to retrieve posts before. Accepts strtotime()-compatible string
- *
- *
- * @return string
- */
- function displaySermons( $atts = array() ) {
- global $post_ID;
-
- // enqueue scripts and styles
- if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
- define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
- }
-
- // unquote
- if ( is_array( $atts ) || is_object( $atts ) ) {
- foreach ( $atts as &$att ) {
- $att = $this->_unquote( $att );
- }
- }
-
- // default options
- $args = array(
- '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',
- 'hide_pagination' => 'disable_pagination',
- );
-
- foreach ( $old_options as $old_option => $new_option ) {
- if ( ! empty( $atts[ $old_option ] ) ) {
- $args[ $new_option ] = $atts[ $old_option ];
- unset( $atts[ $old_option ] );
- }
- }
-
- // merge default and user options
- $args = shortcode_atts( $args, $atts, 'sermons' );
-
- // set query args
- $query_args = array(
- 'post_type' => 'wpfc_sermon',
- 'posts_per_page' => $args['per_page'],
- 'order' => $args['order'],
- 'paged' => get_query_var( 'paged' ),
- 'year' => $args['year'],
- 'month' => $args['month'],
- 'week' => $args['week'],
- 'day' => $args['day'],
- 'after' => $args['after'],
- 'before' => $args['before'],
- 'meta_query' => array(
- 'relation' => 'OR',
- array( //check to see if date has been filled out
- 'key' => 'sermon_date',
- 'compare' => '<=',
- 'value' => time()
- ),
- array( //if no date has been added show these posts too
- 'key' => 'sermon_date',
- 'value' => time(),
- 'compare' => 'NOT EXISTS'
- )
- ),
- );
-
- // check if it's a valid ordering argument
- if ( ! in_array( strtolower( $args['orderby'] ), array(
- 'date',
- 'id',
- 'none',
- 'title',
- 'name',
- 'rand',
- 'comment_count'
- ) ) ) {
- $args['orderby'] = 'date';
- }
-
- if ( $args['orderby'] === 'date' ) {
- $args['orderby'] = 'meta_value_num';
- }
-
- $query_args['orderby'] = $args['orderby'];
-
- // if we should show just specific sermons
- if ( $args['sermons'] ) {
- $posts_in = explode( ',', $args['sermons'] );
-
- if ( ! empty( $posts_in ) ) {
- foreach ( $posts_in as &$post_in ) {
- // remove if it's not an ID
- if ( ! is_numeric( trim( $post_in ) ) ) {
- unset( $post_in );
- continue;
- }
-
- // convert to int
- $post_in = intval( trim( $post_in ) );
- }
-
- $query_args['post__in'] = $posts_in;
- }
- }
-
- // if we should filter by something
- if ( $args['filter_by'] && $args['filter_value'] ) {
- // Term string to array
- $terms = explode( ',', $args['filter_value'] );
-
- if ( ! empty( $terms ) ) {
- $field = 'slug';
-
- if ( is_numeric( $terms[0] ) ) {
- $field = 'id';
- }
-
- foreach ( $terms as &$term ) {
- $term = trim( $term );
-
- if ( $field === 'id' ) {
- // remove if it's not an ID
- if ( ! is_numeric( $term ) ) {
- unset( $term );
- continue;
- }
-
- // convert to int
- $term = intval( $term );
- }
- }
-
- $query_args['tax_query'] = array(
- array(
- 'taxonomy' => $this->convertTaxonomyName( $args['filter_by'], false ),
- 'field' => 'slug',
- 'terms' => $terms,
- )
- );
- }
- }
-
- foreach ( array( 'wpfc_preacher', 'wpfc_sermon_series', 'wpfc_sermon_topics', 'wpfc_bible_book' ) as $filter ) {
- if ( ! empty( $_GET[ $filter ] ) ) {
- if ( empty( $query_args['tax_query']['custom'] ) || empty( $query_args['tax_query'] ) ) {
- $query_args['tax_query'] = array();
- }
-
- $query_args['tax_query'][0][] = array(
- 'taxonomy' => $filter,
- 'field' => 'slug',
- 'terms' => sanitize_title_for_query( $_GET[ $filter ] ),
- );
-
- $query_args['tax_query']['custom'] = true;
- }
- }
-
- if ( ! empty( $query_args['tax_query'] ) && count( $query_args['tax_query'] ) > 1 && ! empty( $query_args['tax_query']['custom'] ) ) {
- unset( $query_args['tax_query']['custom'] );
- }
-
- $query = new WP_Query( $query_args );
-
- // set image size
- add_filter( 'wpfc_sermon_excerpt_sermon_image_size', function () use ( $args ) {
- return $args['image_size'];
- } );
-
- define( 'wpfc_sm_shortcode', true );
-
- if ( $query->have_posts() ) {
- ob_start(); ?>
-
- have_posts() ) : $query->the_post();
- global $post; ?>
- = apply_filters( 'sm_shortcode_sermons_single_output', '
' . wpfc_sermon_excerpt_v2( true ) . '
', $post ); ?>
-
-
-
-
-
-
- $query ) ); ?>
-
-
- rtrim( get_permalink( $post_ID ), '/' ) . '/%_%',
- 'current' => $query->get( 'paged' ),
- 'total' => $query->max_num_pages,
- 'end_size' => 3,
- ) );
- ?>
-
-
-
-
- init();
\ No newline at end of file
+legacy_shortcodes();
+ }
+
+ /**
+ * Get new instance self or current one if exists.
+ *
+ * @return SM_Shortcodes
+ */
+ public static function get_instance() {
+ if ( null === self::$instance ) {
+ self::$instance = new self;
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * They are here for compatibility purposes.
+ */
+ public function legacy_shortcodes() {
+ add_shortcode( 'list-sermons', array( self::get_instance(), 'display_sermons_list' ) );
+ add_shortcode( 'sermon-images', array( self::get_instance(), 'display_images' ) );
+ }
+
+ /**
+ * Display an unordered list of series, preachers, topics or books.
+ *
+ * @param array[] $atts Shortcode parameters.
+ *
+ * @type string $atts ['display'] The taxonomy, possible options: series, preachers, topics, books.
+ * @type string $atts ['order'] Sorting order, possible options: ASC, DESC.
+ * @type string $atts ['ordrerby'] Possible options: id, count, name, slug, term_group, none.
+ *
+ * @return string List or error message.
+ */
+ public function display_sermons_list( $atts ) {
+ // Enqueue scripts and styles.
+ if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
+ define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
+ }
+
+ // Unquote.
+ if ( is_array( $atts ) || is_object( $atts ) ) {
+ foreach ( $atts as &$att ) {
+ $att = $this->_unquote( $att );
+ }
+ }
+
+ // Default options.
+ $args = array(
+ 'display' => 'series',
+ 'order' => 'ASC',
+ 'orderby' => 'name',
+ );
+
+ // For compatibility.
+ if ( ! empty( $atts['tax'] ) ) {
+ $atts['display'] = $atts['tax'];
+ unset( $atts['tax'] );
+ }
+
+ // For compatibility.
+ if ( ! empty( $atts['taxonomy'] ) ) {
+ $atts['display'] = $atts['taxonomy'];
+ unset( $atts['taxonomy'] );
+ }
+
+ // Join default and user options.
+ $args = shortcode_atts( $args, $atts, 'list_sermons' );
+
+ // Check if we are using a SM taxonomy, and if we are, convert to valid taxonomy name.
+ if ( $this->convert_taxonomy_name( $args['display'], true ) ) {
+ $args['display'] = $this->convert_taxonomy_name( $args['display'], false );
+ } elseif ( ! $this->convert_taxonomy_name( $args['display'], false ) ) {
+ return 'Error: Invalid "list" parameter. Possible values are: "series", "preachers", "topics" and "books". You entered: "' . $args['display'] . ' "';
+ }
+
+ $query_args = array(
+ 'taxonomy' => $args['display'],
+ 'orderby' => $args['orderby'],
+ 'order' => $args['order'],
+ );
+
+ if ( 'date' === $query_args['orderby'] ) {
+ $query_args['orderby'] = 'meta_value_num';
+ $query_args['meta_key'] = 'sermon_date';
+ $query_args['meta_compare'] = '<=';
+ $query_args['meta_value_num'] = time();
+ }
+
+ // Get items.
+ $terms = get_terms( $query_args );
+
+ if ( count( $terms ) > 0 ) {
+ // Sort books by order.
+ if ( 'wpfc_bible_book' === $args['display'] && 'book' === $args['orderby'] ) {
+ // 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;
+ }
+
+ $list = '';
+
+ return $list;
+ } else {
+ // If nothing has been found.
+ return 'No ' . $this->convert_taxonomy_name( $args['display'], true ) . ' found.';
+ }
+ }
+
+ /**
+ * 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.
+ *
+ * @param string $name User friendly name or taxonomy name.
+ * @param bool $new_name Should it return user friendly name.
+ *
+ * @return string|null null if nothing found, name otherwise
+ */
+ public function convert_taxonomy_name( $name, $new_name ) {
+ $old_taxonomies = array(
+ 'wpfc_sermon_series',
+ 'wpfc_preacher',
+ 'wpfc_sermon_topics',
+ 'wpfc_bible_book',
+ 'wpfc_service_type',
+ );
+ $new_taxonomies = array( 'series', 'preachers', 'topics', 'books', 'service_types' );
+
+ if ( $new_name ) {
+ if ( in_array( $name, $old_taxonomies ) ) {
+ return $new_taxonomies[ array_search( $name, $old_taxonomies ) ];
+ }
+
+ // Return itself if it's already converted. try plural if (assumed) singular doesn't exist.
+ foreach ( array( $name, $name . 's' ) as $name_s ) {
+ if ( in_array( $name_s, $new_taxonomies ) ) {
+ return $name_s;
+ }
+ }
+ } else {
+ // Try plural if (assumed) singular doesn't exist.
+ foreach ( array( $name, $name . 's' ) as $name_s ) {
+ if ( in_array( $name_s, $new_taxonomies ) ) {
+ return $old_taxonomies[ array_search( $name_s, $new_taxonomies ) ];
+ }
+ }
+
+ // Return itself if it's already converted.
+ if ( in_array( $name, $old_taxonomies ) ) {
+ return $name;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Display all series or speakers in a grid of images
+ *
+ * @param array $atts Shortcode parameters.
+ *
+ * @type string $atts ['display'] The taxonomy, possible options: series, preachers.
+ * @type string $atts ['order'] Sorting order, possible options: ASC, DESC.
+ * @type string $atts ['ordrerby'] Possible options: id, count, name, slug, term_group, none.
+ * @type string $atts ['size'] Possible options: sermon_small, sermon_medium, sermon_wide, thumbnail, medium,
+ * large, full, or any size added with add_image_size().
+ * @type bool $atts ['hide_title'] Should we hide title, default false.
+ * @type bool $atts ['show_description'] Should we show the description, default false.
+ *
+ * @return string Grid or error message.
+ */
+ public function display_images( $atts = array() ) {
+ // Enqueue scripts and styles.
+ if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
+ define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
+ }
+
+ // Unquote.
+ if ( is_array( $atts ) || is_object( $atts ) ) {
+ foreach ( $atts as &$att ) {
+ $att = $this->_unquote( $att );
+ }
+ }
+
+ // Default args.
+ $args = array(
+ 'display' => 'series',
+ 'order' => 'DESC',
+ 'orderby' => 'name',
+ 'size' => 'sermon_medium',
+ 'hide_title' => false,
+ 'show_description' => false,
+ );
+
+ // For compatibility.
+ if ( ! empty( $atts['tax'] ) ) {
+ $atts['display'] = $atts['tax'];
+ unset( $atts['tax'] );
+ }
+
+ // For compatibility.
+ if ( ! empty( $atts['show_desc'] ) ) {
+ $atts['show_description'] = $atts['show_desc'];
+ unset( $atts['show_desc'] );
+ }
+
+ // Join default and user options.
+ $args = shortcode_atts( $args, $atts, 'sermon_images' );
+
+ // Convert to bool.
+ $args['show_description'] = (bool) $args['show_description'];
+
+ // Check if we are using a SM taxonomy, and if we are, convert to valid taxonomy name.
+ if ( $this->convert_taxonomy_name( $args['display'], true ) ) {
+ $args['display'] = $this->convert_taxonomy_name( $args['display'], false );
+ } elseif ( ! $this->convert_taxonomy_name( $args['display'], false ) ) {
+ return 'Error: Invalid "list" parameter. Possible values are: "series", "preachers", "topics" and "books". You entered: "' . $args['display'] . ' "';
+ }
+
+ // Get images.
+ $terms = apply_filters( 'sermon-images-get-terms', '', array(
+ 'taxonomy' => $args['display'],
+ 'term_args' => array(
+ 'order' => $args['order'],
+ 'orderby' => $args['orderby'],
+ ),
+ ) );
+
+ // $terms will always return an array
+ if ( ! empty( $terms ) ) {
+ $list = '';
+
+ return $list;
+ } else {
+ // If nothing has been found.
+ return 'No ' . $this->convert_taxonomy_name( $args['display'], true ) . ' images found.';
+ }
+ }
+
+ /**
+ * Display the latest sermon series image (optional - by service type).
+ *
+ * @param array $atts Shortcode options.
+ *
+ * @type string $atts ['image_class'] CSS class for image.
+ * @type string $atts ['size'] Image size. Possible options: sermon_small, sermon_medium, sermon_wide, thumbnail,
+ * medium, large, full, or any size added with add_image_size().
+ * @type bool $atts ['show_title'] false to hide the series title (true is the default).
+ * @type string $atts ['title_wrapper'] Possible options: p, h1, h2, h3, h4, h5, h6, div.
+ * @type string $atts ['title_class'] CSS class for title.
+ * @type string $atts ['service_type'] Service type ID/slug/name. Used to get latest series from that service type.
+ * @type bool $atts ['show_description'] false to hide the series description (true is the default).
+ * @type string $atts ['wrapper_class'] CSS class for wrapper.
+ *
+ * @return string
+ */
+ function display_latest_series_image( $atts = array() ) {
+ // Enqueue scripts and styles.
+ if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
+ define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
+ }
+
+ // Unquote.
+ if ( is_array( $atts ) || is_object( $atts ) ) {
+ foreach ( $atts as &$att ) {
+ $att = $this->_unquote( $att );
+ }
+ }
+
+ // Default options.
+ $args = array(
+ 'image_class' => 'latest-series-image',
+ 'size' => 'large',
+ 'show_title' => 'yes',
+ 'title_wrapper' => 'h3',
+ 'title_class' => 'latest-series-title',
+ 'service_type' => '',
+ 'show_description' => 'yes',
+ 'wrapper_class' => 'latest-series',
+ );
+
+ // For compatibility.
+ if ( ! empty( $atts['show_desc'] ) ) {
+ $atts['show_description'] = $atts['show_desc'];
+ unset( $atts['show_desc'] );
+ }
+
+ // Join default and user options.
+ $args = shortcode_atts( $args, $atts, 'latest_series' );
+
+ // Get latest series.
+ $latest_series = $this->get_latest_series( 0, $args['service_type'] );
+
+ // If for some reason we couldn't get latest series.
+ if ( null === $latest_series ) {
+ return 'No latest series found.';
+ }
+
+ // Image ID.
+ $series_image_id = $this->get_latest_series_image_id( $latest_series );
+
+ // If for some reason we couldn't get latest series image.
+ if ( null === $series_image_id ) {
+ return 'No latest series image found.';
+ }
+
+ // Link to series.
+ $series_link = get_term_link( $latest_series, 'wpfc_sermon_series' );
+ // Image CSS class.
+ $image_class = sanitize_html_class( $args['image_class'] );
+ // Title wrapper tag name.
+ $wrapper_options = array( 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div' );
+ if ( ! in_array( sanitize_text_field( $args['title_wrapper'] ), $wrapper_options ) ) {
+ $args['title_wrapper'] = 'h3';
+ }
+ // Title CSS class.
+ $title_class = sanitize_html_class( $args['title_class'] );
+
+ $link_open = '';
+ $link_close = ' ';
+
+ $image = wp_get_attachment_image( $series_image_id, $args['size'], false, array( 'class' => $image_class ) );
+
+ $title = '';
+ $description = '';
+ if ( 'yes' === $args['show_title'] ) {
+ $title = $latest_series->name;
+ $title = '<' . $args['title_wrapper'] . ' class="' . $title_class . '">' . $title . '' . $args['title_wrapper'] . '>';
+ }
+ if ( 'yes' === $args['show_description'] ) {
+ $description = '' . wpautop( $latest_series->description ) . '
';
+ }
+
+ $wrapper_class = sanitize_html_class( $args['wrapper_class'] );
+ $before = '';
+ $after = '
';
+
+ $output = $before . $link_open . $image . $title . $link_close . $description . $after;
+
+ return $output;
+ }
+
+ /**
+ * Get all sermon series as WP_Term object.
+ *
+ * @param int $latest_sermon Optional. Latest sermon ID. If not provided, it will try to get it automatically.
+ * @param int $service_type Optional. Service Type for getting latest sermon ID.
+ *
+ * @return WP_Term|null
+ */
+ public function get_latest_series( $latest_sermon = 0, $service_type = 0 ) {
+ if ( empty( $latest_sermon ) ) {
+ $latest_sermon = $this->get_latest_sermon_id( $service_type );
+ }
+
+ $latest_series = get_the_terms( $latest_sermon, 'wpfc_sermon_series' );
+
+ if ( is_array( $latest_series ) && ! empty( $latest_series ) ) {
+ return $latest_series[0];
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the latest sermon ID.
+ *
+ * @param string|int $service_type Optional argument to get latest sermon from specified service type. Slug, name
+ * and ID are accepted values.
+ *
+ * @return int|null Sermon ID on success, null on failure.
+ */
+ public function get_latest_sermon_id( $service_type = 0 ) {
+ $args = array(
+ 'post_type' => 'wpfc_sermon',
+ 'posts_per_page' => 1,
+ 'post_status' => 'publish',
+ 'no_found_rows' => true,
+ 'update_post_term_cache' => false,
+ 'update_post_meta_cache' => false,
+ );
+
+ // If service type is set.
+ if ( 0 !== $service_type ) {
+ /*
+ * if it's not numeric, we will try to find it by slug;
+ * if not found by slug, we will try to find it by name.
+ */
+ if ( ! is_numeric( $service_type ) ) {
+ foreach ( array( 'slug', 'name' ) as $field ) {
+ $service_type = get_term_by( $field, $service_type, 'wpfc_service_type' );
+
+ if ( false !== $service_type ) {
+ $service_type = intval( $service_type->term_id );
+ break;
+ }
+ }
+ } else {
+ // Convert to int, if string number is used.
+ $service_type = intval( $service_type );
+ }
+
+ if ( is_int( $service_type ) && term_exists( $service_type, 'wpfc_service_type' ) ) {
+ $args['tax_query'] = array(
+ 'taxonomy' => 'wpfc_service_type',
+ 'terms' => $service_type,
+ );
+ }
+ }
+
+ $latest_sermon = new WP_Query( $args );
+
+ // If there is a post, return ID.
+ if ( ! empty( $latest_sermon->post_count ) ) {
+ wp_reset_postdata();
+
+ return $latest_sermon->post->ID;
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the image ID of the specified series ID.
+ * Will try to get image ID of latest series if $latest_series argument not set.
+ *
+ * @param int $series Series to get the image of.
+ *
+ * @return int|null
+ */
+ function get_latest_series_image_id( $series = 0 ) {
+ if ( 0 === $series ) {
+ $series = $this->get_latest_series();
+
+ if ( null === $series ) {
+ return null;
+ }
+ }
+
+ $associations = sermon_image_plugin_get_associations();
+ $tt_id = absint( $series->term_taxonomy_id );
+
+ if ( array_key_exists( $tt_id, $associations ) ) {
+ $id = absint( $associations[ $tt_id ] );
+
+ return $id;
+ }
+
+ return null;
+ }
+
+ /**
+ * Renders sorting HTML.
+ *
+ * @param array $atts Shortcode parameters.
+ *
+ * @type string $series_filter Do filtering in this specific series (slug).
+ * @type string $series Force specific series to show. Slug only.
+ * @type string $preachers Force specific preacher to show. Slug only.
+ * @type string $topics Force specific topic to show. Slug only.
+ * @type string $books Force specific book to show. Slug only.
+ * @type string $visibility 'none' to hide the forced fields, 'disable' to show them as disabled and 'suggest' to
+ * just set the default value while allowing user to change it. Default 'suggest'.
+ *
+ * @return string Sorting HTML.
+ *
+ * @since 2.5.0 added shortcode parameters.
+ */
+ public function display_sermon_sorting( $atts = array() ) {
+ // Enqueue scripts and styles.
+ if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
+ define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
+ }
+
+ // Unquote.
+ if ( is_array( $atts ) || is_object( $atts ) ) {
+ foreach ( $atts as &$att ) {
+ $att = $this->_unquote( $att );
+ }
+ }
+
+ // Default shortcode options.
+ $args = array(
+ 'series_filter' => '',
+ 'service_type_filter' => '',
+ 'series' => '',
+ 'preachers' => '',
+ 'topics' => '',
+ 'books' => '',
+ 'visibility' => 'suggest',
+ 'hide_topics' => '',
+ 'hide_series' => '',
+ 'hide_preachers' => '',
+ 'hide_books' => '',
+ 'hide_service_types' => 'yes',
+ );
+
+ // Merge default and user options.
+ $args = shortcode_atts( $args, $atts, 'sermon_sort_fields' );
+
+ return render_wpfc_sorting( $args );
+ }
+
+ /**
+ * Main sermon display code
+ *
+ * @param array $atts Shortcode parameters.
+ *
+ * @type int $atts ['per_page'] How many sermons per page.
+ * @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 ['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 "post-thumbnail").
+ * @type string $atts ['filter_by'] Filter by series, preacher, topic, book, service_type.
+ * @type string $atts ['filter_value'] ID/slug of allowed filters.
+ * @type int $atts ['year'] 4 digit year (e.g. 2011).
+ * @type int $atts ['month'] Month number (from 1 to 12).
+ * @type int $atts ['week'] Week of the year (from 0 to 53).
+ * @type int $atts ['day'] Day of the month (from 1 to 31).
+ * @type string $atts ['after'] Date to retrieve posts after. Accepts strtotime()-compatible string.
+ * @type string $atts ['before'] Date to retrieve posts before. Accepts strtotime()-compatible string.
+ *
+ * @return string
+ */
+ function display_sermons( $atts = array() ) {
+ global $post_ID;
+
+ // Enqueue scripts and styles.
+ if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
+ define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
+ }
+
+ // Unquote.
+ if ( is_array( $atts ) || is_object( $atts ) ) {
+ foreach ( $atts as &$att ) {
+ $att = $this->_unquote( $att );
+ }
+ }
+
+ // Default options.
+ $args = array(
+ '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' => 'post-thumbnail',
+ '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',
+ 'hide_pagination' => 'disable_pagination',
+ );
+
+ foreach ( $old_options as $old_option => $new_option ) {
+ if ( ! empty( $atts[ $old_option ] ) ) {
+ $args[ $new_option ] = $atts[ $old_option ];
+ unset( $atts[ $old_option ] );
+ }
+ }
+
+ // Merge default and user options.
+ $args = shortcode_atts( $args, $atts, 'sermons' );
+
+ // Set query args.
+ $query_args = array(
+ 'post_type' => 'wpfc_sermon',
+ 'posts_per_page' => $args['per_page'],
+ 'order' => $args['order'],
+ 'paged' => get_query_var( 'paged' ),
+ 'year' => $args['year'],
+ 'month' => $args['month'],
+ 'week' => $args['week'],
+ 'day' => $args['day'],
+ 'after' => $args['after'],
+ 'before' => $args['before'],
+ );
+
+ // Check if it's a valid ordering argument.
+ if ( ! in_array( strtolower( $args['orderby'] ), array(
+ 'date',
+ 'id',
+ 'none',
+ 'title',
+ 'name',
+ 'rand',
+ 'comment_count',
+ ) ) ) {
+ $args['orderby'] = 'date';
+ }
+
+ if ( 'date' === $args['orderby'] ) {
+ $args['orderby'] = 'meta_value_num';
+
+ $query_args['meta_key'] = 'sermon_date';
+ $query_args['meta_value_num'] = time();
+ $query_args['meta_compare'] = '<=';
+ }
+
+ $query_args['orderby'] = $args['orderby'];
+
+ // If we should show just specific sermons.
+ if ( $args['sermons'] ) {
+ $posts_in = explode( ',', $args['sermons'] );
+
+ if ( ! empty( $posts_in ) ) {
+ foreach ( $posts_in as &$post_in ) {
+ // Remove if it's not an ID.
+ if ( ! is_numeric( trim( $post_in ) ) ) {
+ unset( $post_in );
+ continue;
+ }
+
+ // Convert to int.
+ $post_in = intval( trim( $post_in ) );
+ }
+
+ $query_args['post__in'] = $posts_in;
+ }
+ }
+
+ // If we should filter by something.
+ if ( $args['filter_by'] && $args['filter_value'] ) {
+ // Term string to array.
+ $terms = explode( ',', $args['filter_value'] );
+
+ if ( ! empty( $terms ) ) {
+ $field = 'slug';
+
+ if ( is_numeric( $terms[0] ) ) {
+ $field = 'id';
+ }
+
+ foreach ( $terms as &$term ) {
+ $term = trim( $term );
+
+ if ( 'id' === $field ) {
+ // Remove if it's not an ID.
+ if ( ! is_numeric( $term ) ) {
+ unset( $term );
+ continue;
+ }
+
+ // Convert to int.
+ $term = intval( $term );
+ }
+ }
+
+ $query_args['tax_query'] = array(
+ array(
+ 'taxonomy' => $this->convert_taxonomy_name( $args['filter_by'], false ),
+ 'field' => 'slug',
+ 'terms' => $terms,
+ ),
+ );
+ }
+ }
+
+ foreach ( array( 'wpfc_preacher', 'wpfc_sermon_series', 'wpfc_sermon_topics', 'wpfc_bible_book' ) as $filter ) {
+ if ( ! empty( $_GET[ $filter ] ) ) {
+ if ( empty( $query_args['tax_query']['custom'] ) || empty( $query_args['tax_query'] ) ) {
+ $query_args['tax_query'] = array();
+ }
+
+ $query_args['tax_query'][0][] = array(
+ 'taxonomy' => $filter,
+ 'field' => 'slug',
+ 'terms' => sanitize_title_for_query( $_GET[ $filter ] ),
+ );
+
+ $query_args['tax_query']['custom'] = true;
+ }
+ }
+
+ if ( ! empty( $query_args['tax_query'] ) && count( $query_args['tax_query'] ) > 1 && ! empty( $query_args['tax_query']['custom'] ) ) {
+ unset( $query_args['tax_query']['custom'] );
+ }
+
+ $query = new WP_Query( $query_args );
+
+ // Set image size.
+ add_filter( 'wpfc_sermon_excerpt_sermon_image_size', function () use ( $args ) {
+ return $args['image_size'];
+ } );
+
+ define( 'WPFC_SM_SHORTCODE', true );
+
+ if ( $query->have_posts() ) {
+ ob_start(); ?>
+
+ have_posts() ) :
+ $query->the_post();
+ global $post;
+ ?>
+ ' . wpfc_sermon_excerpt_v2( true, $args ) . '
', $post ); ?>
+
+
+
+
+
+
+ $query ) ); ?>
+
+
+ preg_replace( '/\/\?.*/', '', rtrim( get_permalink( $post_ID ), '/' ) ) . '/%_%',
+ 'current' => $query->get( 'paged' ),
+ 'total' => $query->max_num_pages,
+ 'end_size' => 3,
+ 'add_args' => $add_args,
+ ) );
+ ?>
+
+
+
+
+ init();
diff --git a/includes/class-sm-widget-recent-sermons.php b/includes/class-sm-widget-recent-sermons.php
new file mode 100755
index 0000000..9ff1094
--- /dev/null
+++ b/includes/class-sm-widget-recent-sermons.php
@@ -0,0 +1,226 @@
+ 'widget_recent_sermons',
+ 'description' => __( 'The most recent sermons on your site', 'sermon-manager-for-wordpress' ),
+ );
+ parent::__construct( 'recent-sermons', __( 'Recent Sermons', 'sermon-manager-for-wordpress' ), $widget_ops );
+ $this->alt_option_name = 'widget_recent_entries';
+
+ add_action( 'save_post', array( $this, 'flush_widget_cache' ) );
+ add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) );
+ add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) );
+ }
+
+ /**
+ * Renders the widget.
+ *
+ * @param array $args Render arguments.
+ * @param array $instance Widget instance.
+ */
+ function widget( $args, $instance ) {
+ // Enqueue scripts and styles.
+ if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
+ define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
+ }
+
+ $cache = wp_cache_get( 'widget_recent_sermons', 'widget' );
+
+ if ( ! is_array( $cache ) ) {
+ $cache = array();
+ }
+
+ /**
+ * Filter: Allows to override the cache.
+ *
+ * @since 2.13.0
+ */
+ if ( isset( $cache[ $args['widget_id'] ] ) && ! apply_filters( 'sm_recent_sermons_widget_override_cache', false ) ) {
+ echo $cache[ $args['widget_id'] ];
+
+ return;
+ }
+
+ ob_start();
+
+ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Sermons', 'sermon-manager-for-wordpress' ) : $instance['title'], $instance, $this->id_base );
+ $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
+ $before_widget = isset( $instance['before_widget'] ) ? wp_kses_post( $instance['before_widget'] ) : '';
+ $after_widget = isset( $instance['after_widget'] ) ? wp_kses_post( $instance['after_widget'] ) : '';
+
+ $r = new WP_Query( array(
+ 'post_type' => 'wpfc_sermon',
+ 'posts_per_page' => $number,
+ 'no_found_rows' => true,
+ 'post_status' => 'publish',
+ 'ignore_sticky_posts' => true,
+ 'meta_key' => 'sermon_date',
+ 'meta_value_num' => time(),
+ 'meta_compare' => '<=',
+ 'orderby' => 'meta_value_num',
+ 'order' => 'desc',
+ ) );
+ if ( $r->have_posts() ) {
+ ?>
+
+
+
+
+
+
+
+
+
+
+ have_posts() ) : ?>
+ the_post();
+ global $post;
+
+ $terms = get_the_terms( $post->ID, 'wpfc_preacher' );
+ $preacher_links = array();
+ if ( $terms ) {
+ foreach ( $terms as $term ) {
+ $preacher_links[] = $term->name;
+ }
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+ flush_widget_cache();
+
+ $all_options = wp_cache_get( 'alloptions', 'options' );
+ if ( isset( $all_options['widget_recent_entries'] ) ) {
+ delete_option( 'widget_recent_entries' );
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Clears widget cache.
+ */
+ function flush_widget_cache() {
+ wp_cache_delete( 'widget_recent_sermons', 'widget' );
+ }
+
+ /**
+ * Outputs widget settings.
+ *
+ * @param array $instance Widget instance.
+ *
+ * @return void
+ */
+ function form( $instance ) {
+ $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
+ $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
+ $before_widget = isset( $instance['before_widget'] ) ? wp_kses_post( $instance['before_widget'] ) : '';
+ $after_widget = isset( $instance['after_widget'] ) ? wp_kses_post( $instance['after_widget'] ) : '';
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ';
- $title_html .= $title;
- $title_html .= '';
- } else {
- $title_html = '';
- }
-
- return $title_html;
-
-}
-
-function wpfc_get_sermon_description( $id ) {
-
- if ( empty( $id ) ) {
- $id = '';
- }
-
- $sermon_description = '';
-
- $sermon_description = get_post_meta( $id, 'sermon_description', true );
-
- return $sermon_description;
-
-}
-
-function wpfc_get_sermon_description_html( $id ) {
-
- $description = wpfc_get_sermon_description( $id );
- if ( empty( $description ) ) {
- $description_html = '';
- } else {
- $description_html = '';
- $description_html .= $description;
- $description_html .= '
';
- }
-
- return $description_html;
-
-}
-
-function wpfc_get_sermon_video( $id ) {
-
- $sermon_video = get_post_meta( $id, 'sermon_video', true );
-
- if ( empty( $sermon_video ) ) {
- $sermon_video = '';
- }
-
- return $sermon_video;
-
-}
-
-function wpfc_get_sermon_notes( $id ) {
-
- $sermon_notes = get_post_meta( $id, 'sermon_notes', true );
-
- if ( empty( $sermon_notes ) ) {
- $sermon_notes = '';
- }
-
- return $sermon_notes;
-
-}
-
-function wpfc_get_sermon_audio( $id ) {
-
- $sermon_audio = get_post_meta( $id, 'sermon_audio', true );
-
- if ( empty( $sermon_audio ) ) {
- $sermon_audio = '';
- }
-
- return $sermon_audio;
-
-}
-
-function wpfc_get_sermon_passage( $id ) {
-
- $sermon_passage = get_post_meta( $id, 'bible_passage', true );
-
- if ( empty( $sermon_passage ) ) {
- $sermon_passage = '';
- }
-
- return $sermon_passage;
-
-}
-
-function wpfc_get_sermon_speaker( $id ) {
-
- $sermon_speaker = get_the_terms( $id, 'wpfc_preacher' );
-
- if ( empty( $sermon_speaker ) || ! is_array( $sermon_speaker ) ) {
- $sermon_speaker = '';
- } else {
- $sermon_speaker = $sermon_speaker[0]->name;
- }
-
- return $sermon_speaker;
-
-}
-
-function wpfc_get_sermon_speaker_html( $id ) {
-
- $speaker = wpfc_get_sermon_speaker( $id );
-
- $speaker_html = '';
- $speaker_html .= $speaker;
- $speaker_html .= ' ';
-
- return $speaker_html;
-
-}
-
-function wpfc_get_sermon_series( $id ) {
-
- $sermon_series = get_the_terms( $id, 'wpfc_sermon_series' );
-
- if ( empty( $sermon_series ) || ! is_array( $sermon_series ) ) {
- $sermon_series = '';
- } else {
- $sermon_series = $sermon_series[0]->name;
- }
-
- return $sermon_series;
-
-}
-
-function wpfc_get_sermon_series_html( $id ) {
-
- $series = wpfc_get_sermon_series( $id );
-
- $series_html = '';
- $series_html .= __( 'Series: ', 'sermon-manager-for-wordpress' );
- $series_html .= $series;
- $series_html .= ' ';
-
- return $series_html;
-
-}
diff --git a/includes/podcast-functions.php b/includes/podcast-functions.php
deleted file mode 100644
index 1c2c11d..0000000
--- a/includes/podcast-functions.php
+++ /dev/null
@@ -1,285 +0,0 @@
-is_main_query() && $query->is_feed() ) {
- if ( is_post_type_archive( 'wpfc_sermon' ) || is_tax( 'wpfc_preacher' ) || is_tax( 'wpfc_sermon_topics' ) || is_tax( 'wpfc_service_type' ) || is_tax( 'wpfc_sermon_series' ) || is_tax( 'wpfc_bible_book' ) ) {
- add_filter( 'get_post_time', 'wpfc_podcast_item_date', 10, 3 );
- add_filter( 'bloginfo_rss', 'wpfc_bloginfo_rss_filter', 10, 2 );
- add_filter( 'wp_title_rss', 'wpfc_modify_podcast_title', 99, 3 );
- add_action( 'rss_ns', 'wpfc_podcast_add_namespace' );
- add_action( 'rss2_ns', 'wpfc_podcast_add_namespace' );
- add_action( 'rss_head', 'wpfc_podcast_add_head' );
- add_action( 'rss2_head', 'wpfc_podcast_add_head' );
- add_action( 'rss_item', 'wpfc_podcast_add_item' );
- add_action( 'rss2_item', 'wpfc_podcast_add_item' );
- add_filter( 'the_content_feed', 'wpfc_podcast_summary', 10, 3 );
- add_filter( 'the_excerpt_rss', 'wpfc_podcast_summary' );
- add_filter( 'rss_enclosure', '__return_empty_string' );
-
- if ( \SermonManager::getOption( 'enable_podcast_html_description' ) ) {
- add_filter( 'the_excerpt_rss', 'wpautop' );
- }
-
- // remove sermons that don't have audio
- $query->set( 'meta_query', array(
- 'relation' => 'AND',
- array(
- 'key' => 'sermon_audio',
- 'compare' => 'EXISTS'
- ),
- array(
- 'key' => 'sermon_audio',
- 'value' => '',
- 'compare' => '!='
- )
- )
- );
-
- if ( intval( \SermonManager::getOption( 'podcasts_per_page' ) ) !== 0 ) {
- $query->set( 'posts_per_rss', intval( \SermonManager::getOption( 'podcasts_per_page' ) ) );
- }
- }
- }
-}
-
-/**
- * Note: Unfinished feature.
- * Take a look at comment at `views/wpfc-podcast-feed.php`.
- *
- * Load the template used for podcast XML.
- *
- * It can be overridden by putting the `wpfc-podcast-feed.php` file in the root of your active theme.
- *
- * @since 2.3.5 Added ability to override the default template
- * @return void
- */
-function wpfc_podcast_render() {
- add_action( 'after_setup_theme', function () {
- if ( $overridden_template = locate_template( 'wpfc-podcast-feed.php' ) ) {
- load_template( $overridden_template );
- } else {
- load_template( SM_PATH . 'views/wpfc-podcast-feed.php' );
- }
-
- exit;
- } );
-}
-
-/**
- * Add iTunes XML Namespace to the XML head
- *
- * @return void
- */
-function wpfc_podcast_add_namespace() {
- echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"';
-}
-
-/**
- * Add iTunes header data
- *
- * @return void
- */
-function wpfc_podcast_add_head() {
- remove_filter( 'the_content', 'add_wpfc_sermon_content' );
-
- $categories = array(
- '0' => '',
- '1' => 'Buddhism',
- '2' => 'Christianity',
- '3' => 'Hinduism',
- '4' => 'Islam',
- '5' => 'Judaism',
- '6' => 'Other',
- '7' => 'Spirituality',
- );
-
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- no
-
-
-
-
-
-
- ID, 'sermon_audio', true ) );
- $audio_p = strrpos( $audio_raw, '/' ) + 1;
- $audio_raw = urldecode( $audio_raw );
- $audio = substr( $audio_raw, 0, $audio_p ) . rawurlencode( substr( $audio_raw, $audio_p ) );
- $speaker = strip_tags( get_the_term_list( $post->ID, 'wpfc_preacher', '', ' & ', '' ) );
- $series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) );
- $topics = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ) );
- $post_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
- $post_image = str_ireplace( 'https://', 'http://', ! empty( $post_image['0'] ) ? $post_image['0'] : '' );
- $audio_duration = get_post_meta( $post->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 = site_url( $audio );
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- &$permalink ) {
- if ( $name === 'wpfc_sermon' ) {
+ if ( 'wpfc_sermon' === $name ) {
continue;
}
@@ -129,9 +131,9 @@ function sm_get_permalink_structure() {
}
/**
- * Allows to easily modify the slugs of sermons and taxonomies
+ * Allows to easily modify the slugs of sermons and taxonomies.
*
- * @param array $permalinks Existing permalinks structure
+ * @param array $permalinks Existing permalinks structure.
*
* @since 2.12.3
*/
@@ -175,8 +177,8 @@ function sm_restore_locale() {
/**
* Display a Sermon Manager help tip.
*
- * @param string $tip Help tip text
- * @param bool $allow_html Allow sanitized HTML if true or escape
+ * @param string $tip Help tip text.
+ * @param bool $allow_html Allow sanitized HTML if true or escape.
*
* @return string
* @since 2.9
@@ -192,11 +194,11 @@ function sm_help_tip( $tip, $allow_html = false ) {
}
/**
- * Get an image size.
+ * Get an image size in pixels, based on ID.
*
* Variable is filtered by sm_get_image_size_{image_size}.
*
- * @param array|string $image_size
+ * @param array|string $image_size The ID.
*
* @return array
* @since 2.9
@@ -216,8 +218,10 @@ function sm_get_image_size( $image_size ) {
$image_size = $width . '_' . $height;
} elseif ( in_array( $image_size, array( 'sermon_small', 'sermon_medium', 'sermon_wide' ) ) ) {
- // reset variables
- $w = $h = $c = null;
+ // Reset variables.
+ $w = null;
+ $h = null;
+ $c = null;
switch ( $image_size ) {
case 'sermon_small':
@@ -259,14 +263,14 @@ function sm_get_image_size( $image_size ) {
/**
* Checks the file extension and gets image size based on filetype.
*
- * @param string $img_loc Image URL
+ * @param string $img_loc Image URL.
*
- * @return array|false Array with first item as width and second as height of false if unable to get data
+ * @return array|false Array with first item as width and second as height of false if unable to get data.
*
* @since 2.10
*/
function sm_get_image_dimensions( $img_loc ) {
- // check if url is set
+ // Check if url is set.
if ( trim( $img_loc ) === '' ) {
return false;
}
@@ -286,31 +290,24 @@ function sm_get_image_dimensions( $img_loc ) {
* Retrieve PNG width and height without downloading/reading entire image.
* Adapted from http://php.net/manual/en/function.getimagesize.php#88793
*
- * @param string $img_loc Image URL
+ * @param string $img_loc Image URL.
*
* @return array|false Array with first item as width and second as height of false if unable to get data
*
* @since 2.10
*/
function sm_get_png_dimensions( $img_loc ) {
- $handle = @fopen( $img_loc, "rb" );
+ $handle = fopen( $img_loc, 'rb' );
- // check if url is accessible or fail gracefully
- if ( $handle === false ) {
+ // Check if url is accessible or fail gracefully.
+ if ( false === $handle ) {
return false;
}
if ( ! feof( $handle ) ) {
$new_block = fread( $handle, 24 );
- if ( $new_block[0] == "\x89" &&
- $new_block[1] == "\x50" &&
- $new_block[2] == "\x4E" &&
- $new_block[3] == "\x47" &&
- $new_block[4] == "\x0D" &&
- $new_block[5] == "\x0A" &&
- $new_block[6] == "\x1A" &&
- $new_block[7] == "\x0A" ) {
- if ( $new_block[12] . $new_block[13] . $new_block[14] . $new_block[15] === "\x49\x48\x44\x52" ) {
+ if ( "\x89" == $new_block[0] && "\x50" == $new_block[1] && "\x4E" == $new_block[2] && "\x47" == $new_block[3] && "\x0D" == $new_block[4] && "\x0A" == $new_block[5] && "\x1A" == $new_block[6] && "\x0A" == $new_block[7] ) {
+ if ( "\x49\x48\x44\x52" === $new_block[12] . $new_block[13] . $new_block[14] . $new_block[15] ) {
$width = unpack( 'H*', $new_block[16] . $new_block[17] . $new_block[18] . $new_block[19] );
$width = hexdec( $width[1] );
@@ -328,7 +325,7 @@ function sm_get_png_dimensions( $img_loc ) {
/**
* Retrieve JPEG width and height without downloading/reading entire image.
*
- * @param string $img_loc Image URL
+ * @param string $img_loc Image URL.
*
* @return array|false
* @since 2.9
@@ -336,10 +333,10 @@ function sm_get_png_dimensions( $img_loc ) {
* @see http://php.net/manual/en/function.getimagesize.php#88793
*/
function sm_get_jpeg_dimensions( $img_loc ) {
- $handle = @fopen( $img_loc, "rb" );
+ $handle = fopen( $img_loc, 'rb' );
- // check if url is accessible or fail gracefully
- if ( $handle === false ) {
+ // Check if url is accessible or fail gracefully.
+ if ( false === $handle ) {
return false;
}
@@ -347,17 +344,17 @@ function sm_get_jpeg_dimensions( $img_loc ) {
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" ) {
+ if ( "\xFF" == $new_block[ $i ] && "\xD8" == $new_block[ $i + 1 ] && "\xFF" == $new_block[ $i + 2 ] && "\xE0" == $new_block[ $i + 3 ] ) {
$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 ] );
+ if ( "\x4A" == $new_block[ $i + 2 ] && "\x46" == $new_block[ $i + 3 ] && "\x49" == $new_block[ $i + 4 ] && "\x46" == $new_block[ $i + 5 ] && "\x00" == $new_block[ $i + 6 ] ) {
+ // 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
+ if ( "\xFF" == $new_block[ $i ] ) {
+ // New block detected, check for SOF marker.
$sof_marker = array(
"\xC0",
"\xC1",
@@ -372,21 +369,22 @@ function sm_get_jpeg_dimensions( $img_loc ) {
"\xCB",
"\xCD",
"\xCE",
- "\xCF"
+ "\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 = 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 ] );
+ // 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 {
@@ -401,7 +399,7 @@ function sm_get_jpeg_dimensions( $img_loc ) {
}
/**
- * Import and assign thumbnail to sermon (or any other post/CPT)
+ * Import and assign thumbnail to sermon (or any other post/CPT).
*
* Accepts remote or local image URL.
*
@@ -413,11 +411,11 @@ function sm_get_jpeg_dimensions( $img_loc ) {
*
* (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 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
+ * 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
+ * @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 ) {
@@ -427,9 +425,19 @@ function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) {
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 ) {
+ // Check if local file.
+ if ( strpos( $image_url, '/' ) === 0 && strpos( $image_url, '//' ) !== 0 ) {
+ if ( ! file_exists( $image_url ) ) {
+ return false;
+ }
+ }
+
+ $attachment_id = attachment_url_to_postid( $image_url );
+ $upload = wp_upload_dir();
+
+ if ( $attachment_id && 0 !== $attachment_id ) {
+ // Continue with execution.
+ } elseif ( $upload && false !== strpos( $image_url, $upload['baseurl'] ) ) {
global $doing_sm_upload;
$doing_sm_upload = true;
@@ -445,7 +453,7 @@ function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) {
$attachment_id = media_handle_sideload( array(
'name' => basename( $matches[0] ),
- 'tmp_name' => $url
+ 'tmp_name' => $url,
), 0 );
$doing_sm_upload = false;
@@ -470,7 +478,7 @@ function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) {
'menu_order' => 0,
'post_type' => 'attachment',
'post_mime_type' => $file['type'],
- 'comment_count' => 0
+ 'comment_count' => 0,
), array(
'%s',
'%s',
@@ -503,7 +511,7 @@ function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) {
}
}
- if ( $post_id === 0 ) {
+ if ( 0 === $post_id ) {
return $attachment_id;
}
@@ -512,15 +520,15 @@ function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) {
}
/**
- * Get real image path in upload directory before it's overwritten
- * And disable image moving
+ * 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 ) {
+ if ( true === $doing_sm_upload ) {
$uploads = wp_get_upload_dir();
$upload_dir_file_path = str_replace( $uploads['basedir'], '', $file['tmp_name'] );
@@ -532,19 +540,19 @@ function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) {
/**
* Update image upload URL and path to the real image path location,
- * only if executed by sm_import_and_set_post_thumbnail()
+ * 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 ) {
+ if ( true === $doing_sm_upload ) {
$uploads = wp_get_upload_dir();
$data = array(
'file' => $uploads['basedir'] . $upload_dir_file_path,
'url' => $uploads['baseurl'] . $upload_dir_file_path,
- 'type' => $data['type']
+ 'type' => $data['type'],
);
}
@@ -552,16 +560,16 @@ function sm_import_and_set_post_thumbnail( $image_url, $post_id = 0 ) {
} );
/**
- * Gets sermon series image url
+ * Gets sermon series image URL.
*
- * @param int $series_id ID of the series
+ * @param int $series_id ID of the series.
*
- * @return string|null Image URL; null if image not set or invalid/not set series id
+ * @return string|null Image URL; null if image not set or invalid/not set series ID.
*
* @since 2.11.0
*/
function get_sermon_series_image_url( $series_id = 0 ) {
- if ( ! ( is_int( $series_id ) && $series_id !== 0 ) ) {
+ if ( ! ( is_int( $series_id ) && 0 !== $series_id ) ) {
return null;
}
@@ -571,7 +579,7 @@ function get_sermon_series_image_url( $series_id = 0 ) {
}
/**
- * Gets dropdown options for a setting in "Debug" tab of Sermon Manager Settings
+ * Gets dropdown options for a setting in "Debug" tab of Sermon Manager Settings.
*
* @return array
*
@@ -603,34 +611,67 @@ function sm_debug_get_update_functions() {
/**
* Returns sermon image URL
*
- * @param bool $fallback If set to true, it will try to get series image URL if sermon image URL is not set
+ * @param bool $fallback If set to true, it will try to get series image URL if sermon image URL is not
+ * set.
+ * @param string|array $image_size The image size. Defaults to "post-thumbnail".
+ * @param bool $force_fallback If it's set to true, it will ignore sermon image, even if it exists, and it will
+ * only use series image.
+ * @param WP_Post $post The sermon object, unless it's defined via global $post.
*
- * @return string Image URL or empty string
+ * @return string Image URL or empty string.
*
* @since 2.12.0
*/
-function get_sermon_image_url( $fallback = true ) {
- if ( get_the_post_thumbnail_url() ) {
- return get_the_post_thumbnail_url();
+function get_sermon_image_url( $fallback = true, $image_size = 'post-thumbnail', $force_fallback = false, $post = null ) {
+ if ( null === $post ) {
+ global $post;
}
- if ( $fallback ) {
+ /**
+ * Allows to filter the image size.
+ *
+ * @param string|array $image_size The image size. Default: "post-thumbnail".
+ * @param bool $fallback Should it get series image if sermon image does not exist.
+ * @param bool $force_fallback Should it ignore sermon image and only use series image.
+ * @param WP_Post $post The sermon object.
+ *
+ * @since 2.13.0
+ */
+ $image_size = apply_filters( 'get_sermon_image_url_image_size', $image_size, $fallback, $force_fallback, $post );
+
+ if ( ! $force_fallback ) {
+ $image = get_the_post_thumbnail_url( $post, $image_size );
+ }
+
+ if ( ( empty( $image ) || ! $image ) && ( $fallback || $force_fallback ) ) {
foreach (
apply_filters( 'sermon-images-get-the-terms', '', array(
- 'post_id' => get_the_ID(),
- 'image_size' => 'medium',
+ 'post_id' => $post->ID,
+ 'image_size' => $image_size,
) ) as $term
) {
- if ( isset( $term->image_id ) && $term->image_id !== 0 ) {
- $image = wp_get_attachment_image_url( $term->image_id, 'full' );
+ if ( isset( $term->image_id ) && 0 !== $term->image_id ) {
+ $image = wp_get_attachment_image_url( $term->image_id, $image_size );
if ( $image ) {
- return $image;
+ break;
}
}
}
}
- return '';
+ $image = ! empty( $image ) ? $image : '';
+
+ /**
+ * Allows to filter the image URL.
+ *
+ * @param string|array $image_size The image size. Default: "post-thumbnail".
+ * @param bool $fallback Should it get series image if sermon image does not exist.
+ * @param bool $force_fallback Should it ignore sermon image and only use series image.
+ * @param WP_Post $post The sermon object.
+ *
+ * @since 2.13.0
+ */
+ return apply_filters( 'get_sermon_image_url_image_size', $image, $fallback, $force_fallback, $post );
}
/**
@@ -643,10 +684,10 @@ function get_sermon_image_url( $fallback = true ) {
* "?t=10:45" => 645
* "?t=01:00:01" => 3601
*
- * @param string $url The URL to the video file
+ * @param string $url The URL to the video file.
*
* @return false|int|null Seconds if successful, null if it couldn't decode the format, and false if the parameter is
- * not set
+ * not set.
*
* @since 2.12.3
*/
@@ -657,11 +698,11 @@ function wpfc_get_media_url_seconds( $url ) {
return false;
}
- // try out hms format first (example: 1h2m3s)
+ // Try out hms format first (example: 1h2m3s).
preg_match( '/t=(\d+h)?(\d+m)?(\d+s)+?/', $url, $hms );
if ( ! empty( $hms ) ) {
for ( $i = 1; $i <= 3; $i ++ ) {
- if ( $hms[ $i ] === '' ) {
+ if ( '' === $hms[ $i ] ) {
continue;
}
@@ -682,17 +723,17 @@ function wpfc_get_media_url_seconds( $url ) {
return $seconds;
}
- // try out colon (example: 25:12)
+ // Try out colon format (example: 25:12).
preg_match( '/t=(\d+:)?(\d+:)?(\d+)+?/', $url, $colons );
if ( ! empty( $colons ) ) {
- // fix hours and minutes if needed
+ // Fix hours and minutes if needed.
if ( empty( $colons[2] ) && ! empty( $colons[1] ) ) {
$colons[2] = $colons[1];
$colons[1] = '';
}
for ( $i = 1; $i <= 3; $i ++ ) {
- if ( $colons[ $i ] === '' ) {
+ if ( '' === $colons[ $i ] ) {
continue;
}
@@ -715,7 +756,7 @@ function wpfc_get_media_url_seconds( $url ) {
return $seconds;
}
- // try out seconds (example: 12 (or 12s))
+ // Try out seconds (example: 12 (or 12s)).
preg_match( '/t=(\d+)/', $url, $seconds );
if ( ! empty( $seconds ) && ! empty( $seconds[1] ) ) {
return intval( $seconds[1] );
@@ -725,21 +766,21 @@ function wpfc_get_media_url_seconds( $url ) {
}
/**
- * Gets previous latest sermon. I.e. orders sermons by meta and finds the previous one
+ * Gets previous latest sermon. I.e. orders sermons by meta and finds the previous one.
*
- * @param $post WP_Post The current sermon, will use global if not defined
+ * @param WP_Post $post The current sermon, will use global if not defined.
*
* @since 2.12.5
*
- * @return WP_Post|null The sermon if found, null otherwise
+ * @return WP_Post|null The sermon if found, null otherwise.
*/
function sm_get_previous_sermon( $post = null ) {
- if ( $post === null ) {
+ if ( null === $post ) {
global $post;
}
- if ( ! $post instanceof WP_Post || $post->post_type !== 'wpfc_sermon' ) {
- _doing_it_wrong( __FUNCTION__, '$post must be an instance of WP_Post', '2.12.5' );
+ if ( ! $post instanceof WP_Post || 'wpfc_sermon' !== $post->post_type ) {
+ _doing_it_wrong( __FUNCTION__, '$post must be an instance of WP_Post.', '2.12.5' );
}
$current_sermon_id = $post->ID;
@@ -751,7 +792,7 @@ function sm_get_previous_sermon( $post = null ) {
'meta_compare' => '<=',
'orderby' => 'meta_value_num',
'order' => 'DESC',
- 'posts_per_page' => - 1
+ 'posts_per_page' => - 1,
) );
for ( $p = 0; $p < count( $query->posts ); $p ++ ) {
@@ -761,21 +802,21 @@ function sm_get_previous_sermon( $post = null ) {
}
/**
- * Allows to filter the return value
+ * Allows to filter the return value.
*
- * @param $the_post WP_Post|null The post if found
+ * @param $the_post WP_Post|null The post if found.
*/
return apply_filters( 'sm_get_previous_sermon', isset( $the_post ) ? $the_post : null );
}
/**
- * Gets next latest sermon. I.e. orders sermons by meta and finds the next one
+ * Gets next latest sermon. I.e. orders sermons by meta and finds the next one.
*
- * @param $post WP_Post The current sermon, will use global if not defined
+ * @param WP_Post $post The current sermon, will use global if not defined.
*
* @since 2.12.5
*
- * @return WP_Post|null The sermon if found, null otherwise
+ * @return WP_Post|null The sermon if found, null otherwise.
*/
function sm_get_next_sermon( $post = null ) {
if ( $post === null ) {
@@ -783,7 +824,7 @@ function sm_get_next_sermon( $post = null ) {
}
if ( ! $post instanceof WP_Post || $post->post_type !== 'wpfc_sermon' ) {
- _doing_it_wrong( __FUNCTION__, '$post must be an instance of WP_Post', '2.12.5' );
+ _doing_it_wrong( __FUNCTION__, '$post must be an instance of WP_Post.', '2.12.5' );
}
$current_sermon_id = $post->ID;
@@ -795,7 +836,7 @@ function sm_get_next_sermon( $post = null ) {
'meta_compare' => '<=',
'orderby' => 'meta_value_num',
'order' => 'DESC',
- 'posts_per_page' => - 1
+ 'posts_per_page' => - 1,
) );
for ( $p = 0; $p < count( $query->posts ); $p ++ ) {
@@ -805,9 +846,30 @@ function sm_get_next_sermon( $post = null ) {
}
/**
- * Allows to filter the return value
+ * Allows to filter the return value.
*
- * @param $the_post WP_Post|null The post if found
+ * @param $the_post WP_Post|null The post if found.
*/
return apply_filters( 'sm_get_next_sermon', isset( $the_post ) ? $the_post : null );
-}
\ No newline at end of file
+}
+
+/**
+ * Saves service type.
+ *
+ * Will be obsolete when we add new meta boxes code.
+ *
+ * @param int $post_ID The sermon ID.
+ */
+function set_service_type( $post_ID ) {
+ if ( isset( $_POST['wpfc_service_type'] ) ) {
+ $term = get_term_by( 'id', $_POST['wpfc_service_type'], 'wpfc_service_type' );
+
+ if ( $term ) {
+ $service_type = $term->slug;
+ }
+
+ wp_set_object_terms( $post_ID, empty( $service_type ) ? null : $service_type, 'wpfc_service_type' );
+ }
+}
+
+add_action( 'save_post', 'set_service_type', 99 );
diff --git a/includes/sm-deprecated-functions.php b/includes/sm-deprecated-functions.php
index 09c4ec0..0ec2b99 100644
--- a/includes/sm-deprecated-functions.php
+++ b/includes/sm-deprecated-functions.php
@@ -2,20 +2,22 @@
/**
* Place where functions come to die.
*
- * @since 2.4.9
+ * @package SM/Graveyard
+ *
+ * @since 2.4.9
*/
-defined( 'ABSPATH' ) or die; // exit if accessed directly
+// Exit if accessed directly.
+defined( 'ABSPATH' ) or die;
-// deprecated
+// Deprecated.
define( 'SM___FILE__', __FILE__ );
define( 'SERMON_MANAGER_PATH', SM_PATH );
define( 'SERMON_MANAGER_URL', SM_URL );
define( 'SERMON_MANAGER_VERSION', SM_VERSION );
-
/**
- * Outputs Sermon date. Wrapper for sm_the_date()
+ * Outputs Sermon date. Wrapper for sm_the_date().
*
* @see sm_the_date()
*
@@ -23,68 +25,66 @@
* @param string $before Optional. Output before the date.
* @param string $after Optional. Output after the date.
*
- * @deprecated deprecated since 2.6, use sm_the_date() instead
+ * @deprecated deprecated since 2.6, use sm_the_date() instead.
*/
function wpfc_sermon_date( $d, $before = '', $after = '' ) {
- sm_the_date( $d, $before = '', $after = '' );
-}
-
-/**
- * Saves service type
- *
- * Will be obsolete when we add new meta boxes code
- *
- * @param int $post_ID
- */
-function set_service_type( $post_ID ) {
- if ( isset( $_POST['wpfc_service_type'] ) ) {
- if ( $term = get_term_by( 'id', $_POST['wpfc_service_type'], 'wpfc_service_type' ) ) {
- $service_type = $term->slug;
- }
-
- wp_set_object_terms( $post_ID, empty( $service_type ) ? null : $service_type, 'wpfc_service_type' );
- }
+ _deprecated_function( __FUNCTION__, '2.13.0', 'sm_the_date' );
+ sm_the_date( $d, $before, $after );
}
-add_action( 'save_post', 'set_service_type', 99 );
-
add_action( 'sermon_media', 'wpfc_sermon_media', 5 );
add_action( 'sermon_audio', 'wpfc_sermon_audio', 5 );
add_action( 'sermon_single', 'wpfc_sermon_single' );
add_action( 'sermon_excerpt', 'wpfc_sermon_excerpt' );
/**
- * @deprecated - see wpfc_sermon_media()
+ * Output attachments.
+ *
+ * @deprecated 2.12.5 - see wpfc_sermon_media().
*/
function wpfc_sermon_files() {
+ _deprecated_function( __FUNCTION__, '2.12.5', 'wpfc_sermon_attachments' );
do_action( 'sermon_media' );
}
/**
- * @deprecated - see wpfc_sermon_single() & wpfc_sermon_single_v2()
+ * Output single sermon.
+ *
+ * @deprecated 2.12.5 - see wpfc_sermon_single() & wpfc_sermon_single_v2().
*/
function render_wpfc_sermon_single() {
+ _deprecated_function( __FUNCTION__, '2.12.5', 'wpfc_sermon_single_v2' );
+
do_action( 'sermon_single' );
}
/**
- * @deprecated - see wpfc_sermon_excerpt() & wpfc_sermon_excerpt_v2()
+ * Output archive sermon.
+ *
+ * @deprecated 2.12.5 - see wpfc_sermon_excerpt() & wpfc_sermon_excerpt_v2().
*/
function render_wpfc_sermon_excerpt() {
+ _deprecated_function( __FUNCTION__, '2.12.5', 'wpfc_sermon_excerpt_v2' );
+
do_action( 'sermon_excerpt' );
}
/**
- * Renders v0 archive the_content
+ * Renders v0 archive the_content.
*
* @deprecated 2.12.0
*/
function render_wpfc_sermon_archive() {
- global $post; ?>
+ _deprecated_function( __FUNCTION__, '2.12.0', 'wpfc_sermon_excerpt_v2' );
+
+ global $post;
+ // translators: Sermon Title.
+ $title = printf( esc_attr__( 'Permalink to %s', 'sermon-manager-for-wordpress' ), the_title_attribute( 'echo=0' ) );
+ ?>
>
+ title=""
+ rel="bookmark">
@@ -93,9 +93,10 @@ function render_wpfc_sermon_archive() {
', ' ' );
the_terms( $post->ID, 'wpfc_service_type', '
(', ' ', ') ' );
- ?>
-
+
+
+ ' . __( 'Bible Text: ', 'sermon-manager-for-wordpress' ), ' | ' );
the_terms( $post->ID, 'wpfc_preacher', '', ' ', ' ' );
the_terms( $post->ID, 'wpfc_sermon_series', '
' . __( 'Series: ', 'sermon-manager-for-wordpress' ), ' ', '
' );
@@ -107,15 +108,17 @@ function render_wpfc_sermon_archive() {
}
/**
- * Renders v1 archive the_content
+ * Renders v1 archive the_content.
*
- * @param bool $return True to return, false to echo (default)
+ * @param bool $return True to return, false to echo (default).
*
* @return string
*
* @deprecated 2.12.2
*/
function wpfc_sermon_excerpt( $return = false ) {
+ _deprecated_function( __FUNCTION__, '2.12.2', 'wpfc_sermon_excerpt_v2' );
+
global $post;
ob_start();
@@ -141,12 +144,12 @@ function wpfc_sermon_excerpt( $return = false ) {
ID, 'wpfc_sermon_series', '
' . __( 'Series: ', 'sermon-manager-for-wordpress' ), ' ', ' ' ); ?>
-
+
-
+
-
+
@@ -177,9 +180,16 @@ function wpfc_sermon_excerpt( $return = false ) {
* Renders v1 single the_content
*
* @deprecated 2.12.0
+ *
+ * @param bool $return Should it echo or return. Default - echo.
+ * @param WP_Post $post The sermon WP_Post instance.
+ *
+ * @return string The output
*/
-function wpfc_sermon_single( $return = false, $post = '' ) {
- if ( $post === '' ) {
+function wpfc_sermon_single( $return = false, $post = null ) {
+ _deprecated_function( __FUNCTION__, '2.12.0', 'wpfc_sermon_single_v2' );
+
+ if ( null === $post || '' === $post ) {
global $post;
}
@@ -194,8 +204,10 @@ function wpfc_sermon_single( $return = false, $post = '' ) {
', ' ' );
the_terms( $post->ID, 'wpfc_service_type', ' (', ' ', ') ' );
- ?>
-
+
+
+ ' . __( 'Bible Text: ', 'sermon-manager-for-wordpress' ), ' | ' );
the_terms( $post->ID, 'wpfc_preacher', '', ', ', ' ' );
the_terms( $post->ID, 'wpfc_sermon_series', '
' . __( 'Series: ', 'sermon-manager-for-wordpress' ), ' ', '
' );
@@ -235,6 +247,10 @@ function wpfc_sermon_single( $return = false, $post = '' ) {
}
/**
+ * Removed.
+ *
+ * @param string $feed_type Removed.
+ *
* @deprecated 2.12.0
*/
function wpfc_podcast_url( $feed_type = 'deprecated' ) {
@@ -242,6 +258,8 @@ function wpfc_podcast_url( $feed_type = 'deprecated' ) {
}
/**
+ * Removed.
+ *
* @deprecated 2.12.0
*/
function wpfc_footer_series() {
@@ -249,6 +267,8 @@ function wpfc_footer_series() {
}
/**
+ * Removed.
+ *
* @deprecated 2.12.0
*/
function wpfc_footer_preacher() {
@@ -256,14 +276,18 @@ function wpfc_footer_preacher() {
}
/**
- * Render sermon audio HTML
+ * Render sermon audio HTML.
*
* @return string
*
* @deprecated 2.12.0
*/
function wpfc_sermon_audio() {
- $html = '';
+ _deprecated_function( __FUNCTION__, '2.12.0', 'wpfc_render_audio' );
+
+ $html = '';
+
+ $html .= '
';
$html .= wpfc_render_audio( get_wpfc_sermon_meta( 'sermon_audio' ) );
$html .= '
';
@@ -271,47 +295,53 @@ function wpfc_sermon_audio() {
}
/**
- * Render sermon image, if not set try series image, if not set too - try preacher
+ * Render sermon image, if not set try series image, if not set too - try preacher.
+ *
+ * @param string $size Image size, supports WP image size.
*
- * @param string $size Image size, supports WP image size
+ * @see get_sermon_image_url()
*
* @deprecated 2.12.0
*/
function render_sermon_image( $size ) {
- //$size = any defined image size in WordPress
+ _deprecated_function( __FUNCTION__, '2.12.0', 'get_sermon_image_url' );
+
+ // $size = any defined image size in WordPress.
if ( has_post_thumbnail() ) :
the_post_thumbnail( $size );
- elseif ( apply_filters( 'sermon-images-list-the-terms', '', array( 'taxonomy' => 'wpfc_sermon_series', ) ) ) :
- // get series image
+ elseif ( apply_filters( 'sermon-images-list-the-terms', '', array( 'taxonomy' => 'wpfc_sermon_series' ) ) ) :
+ // Get series image.
print apply_filters( 'sermon-images-list-the-terms', '', array(
'image_size' => $size,
'taxonomy' => 'wpfc_sermon_series',
'after' => '',
'after_image' => '',
'before' => '',
- 'before_image' => ''
+ 'before_image' => '',
) );
- elseif ( ! has_post_thumbnail() && ! apply_filters( 'sermon-images-list-the-terms', '', array( 'taxonomy' => 'wpfc_sermon_series', ) ) ) :
- // get speaker image
+ elseif ( ! has_post_thumbnail() && ! apply_filters( 'sermon-images-list-the-terms', '', array( 'taxonomy' => 'wpfc_sermon_series' ) ) ) :
+ // Get speaker image.
print apply_filters( 'sermon-images-list-the-terms', '', array(
'image_size' => $size,
'taxonomy' => 'wpfc_preacher',
'after' => '',
'after_image' => '',
'before' => '',
- 'before_image' => ''
+ 'before_image' => '',
) );
endif;
}
/**
- * Renders video and/or audio with wrapper HTML
+ * Renders video and/or audio with wrapper HTML.
*
- * @return string The HTML
+ * @return string The HTML.
*
* @deprecated 2.12.0
*/
function wpfc_sermon_media() {
+ _deprecated_function( __FUNCTION__, '2.12.0', null );
+
$html = '';
if ( get_wpfc_sermon_meta( 'sermon_video_link' ) ) {
@@ -334,8 +364,131 @@ function wpfc_sermon_media() {
}
/**
+ * Removed.
+ *
* @deprecated 2.12.0
*/
function wpfc_sermon_author_filter() {
_deprecated_function( __FUNCTION__, '2.12.0', null );
}
+
+/**
+ * Add podcast data to the WordPress default XML feed.
+ *
+ * @param WP_Query $query The query.
+ *
+ * @return void
+ *
+ * @deprecated 2.13.0
+ */
+function wpfc_podcast_add_hooks( $query ) {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+}
+
+/**
+ * Add iTunes XML Namespace to the XML head.
+ *
+ * @return void
+ * @deprecated 2.13.0
+ */
+function wpfc_podcast_add_namespace() {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+}
+
+/**
+ * Add iTunes header data.
+ *
+ * @return void
+ * @deprecated 2.13.0
+ */
+function wpfc_podcast_add_head() {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+}
+
+/**
+ * Add iTunes data to each sermon.
+ *
+ * @deprecated 2.13.0
+ */
+function wpfc_podcast_add_item() {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+}
+
+/**
+ * Replace feed item content and excerpt with Sermon description.
+ *
+ * @param string $content Original content.
+ *
+ * @return string Modified content.
+ *
+ * @deprecated 2.13.0
+ */
+function wpfc_podcast_summary( $content ) {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+
+ return '';
+}
+
+/**
+ * Replace feed item published date with Sermon date.
+ *
+ * @param string $time The formatted time.
+ * @param string $d Format to use for retrieving the time the post was written.
+ * Accepts 'G', 'U', or php date format. Default 'U'.
+ * @param bool $gmt Whether to retrieve the GMT time. Default false.
+ *
+ * @return string Modified date
+ *
+ * @deprecated 2.13.0
+ */
+function wpfc_podcast_item_date( $time, $d = 'U', $gmt = false ) {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+
+ return '';
+}
+
+/**
+ * Replace feed title with the one defined in Sermon Manager settings.
+ *
+ * @param string $title Default title.
+ *
+ * @return string Modified title.
+ *
+ * @deprecated 2.13.0
+ */
+function wpfc_modify_podcast_title( $title ) {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+
+ return '';
+}
+
+/**
+ * Modifies get_bloginfo output and injects Sermon Manager data.
+ *
+ * @param string $info Default data.
+ * @param string $show Requested data.
+ *
+ * @return string Modified data
+ *
+ * @deprecated 2.13.0
+ */
+function wpfc_bloginfo_rss_filter( $info, $show ) {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+
+ return '';
+}
+
+/**
+ * Note: Unfinished feature.
+ * Take a look at comment at `views/wpfc-podcast-feed.php`.
+ *
+ * Load the template used for podcast XML.
+ *
+ * It can be overridden by putting the `wpfc-podcast-feed.php` file in the root of your active theme.
+ *
+ * @since 2.3.5 Added ability to override the default template
+ * @return void
+ */
+function wpfc_podcast_render() {
+ _deprecated_function( __FUNCTION__, '2.13.0', null );
+}
diff --git a/includes/sm-formatting-functions.php b/includes/sm-formatting-functions.php
index 4db5c99..505fe55 100644
--- a/includes/sm-formatting-functions.php
+++ b/includes/sm-formatting-functions.php
@@ -1,6 +1,8 @@
array(),
'p' => array(),
) ) );
-}
\ No newline at end of file
+}
diff --git a/includes/sm-podcast-functions.php b/includes/sm-podcast-functions.php
new file mode 100644
index 0000000..e52c3f6
--- /dev/null
+++ b/includes/sm-podcast-functions.php
@@ -0,0 +1,49 @@
+taxonomy . '.php';
if ( ! file_exists( get_stylesheet_directory() . '/' . $default_file ) ) {
@@ -45,11 +53,11 @@
}
/**
- * Replaces default the_content and/or the_excerpt with proper sermon content
+ * Replaces default the_content and/or the_excerpt with proper sermon content.
*
- * @param string $content The default content
+ * @param string $content The default content.
*
- * @return string The modified content if it's Sermon related data
+ * @return string The modified content if it's Sermon related data.
*/
function add_wpfc_sermon_content( $content ) {
if ( 'wpfc_sermon' === get_post_type() && in_the_loop() == true ) {
@@ -70,20 +78,20 @@ function add_wpfc_sermon_content( $content ) {
}
/**
- * Render sermon sorting/filtering
+ * Render sermon sorting/filtering.
*
- * @param array $args Display options. See the 'sermon_sort_fields' shortcode for array items
+ * @param array $args Display options. See the 'sermon_sort_fields' shortcode for array items.
*
* @see WPFC_Shortcodes->displaySermonSorting()
*
- * @return string the HTML
+ * @return string The HTML.
*
* @since 2.5.0 added $args
*/
function render_wpfc_sorting( $args = array() ) {
$action = ( SermonManager::getOption( 'home_url_filtering' ) ? home_url() : site_url() ) . '/' . ( SermonManager::getOption( 'common_base_slug' ) ? ( SermonManager::getOption( 'archive_slug' ) ?: 'sermons' ) : '' );
- // Filters HTML fields data
+ // Filters HTML fields data.
$filters = array(
array(
'className' => 'sortPreacher',
@@ -94,22 +102,22 @@ function render_wpfc_sorting( $args = array() ) {
array(
'className' => 'sortSeries',
'taxonomy' => 'wpfc_sermon_series',
- 'title' => __( 'Filter by Series', 'sermon-manager-for-wordpress' )
+ 'title' => __( 'Filter by Series', 'sermon-manager-for-wordpress' ),
),
array(
'className' => 'sortTopics',
'taxonomy' => 'wpfc_sermon_topics',
- 'title' => __( 'Filter by Topic', 'sermon-manager-for-wordpress' )
+ 'title' => __( 'Filter by Topic', 'sermon-manager-for-wordpress' ),
),
array(
'className' => 'sortBooks',
'taxonomy' => 'wpfc_bible_book',
- 'title' => __( 'Filter by Book', 'sermon-manager-for-wordpress' )
+ 'title' => __( 'Filter by Book', 'sermon-manager-for-wordpress' ),
),
array(
'className' => 'sortServiceTypes',
'taxonomy' => 'wpfc_service_type',
- 'title' => __( 'Filter by Service Type', 'sermon-manager-for-wordpress' )
+ 'title' => __( 'Filter by Service Type', 'sermon-manager-for-wordpress' ),
),
);
@@ -121,97 +129,54 @@ function render_wpfc_sorting( $args = array() ) {
'wpfc_service_type' => 'hide_service_types',
);
- if ( empty( $args ) ) {
- $args = array(
- 'series_filter' => '',
- 'service_type_filter' => '',
- 'series' => '',
- 'preachers' => '',
- 'topics' => '',
- 'books' => '',
- 'visibility' => 'suggest',
- 'hide_topics' => '',
- 'hide_series' => '',
- 'hide_preachers' => '',
- 'hide_books' => '',
- 'hide_service_types' => SermonManager::getOption( 'service_type_filtering' ) ? '' : 'yes',
- );
- }
+ $default = array(
+ 'series_filter' => '',
+ 'service_type_filter' => '',
+ 'series' => '',
+ 'preachers' => '',
+ 'topics' => '',
+ 'books' => '',
+ 'visibility' => 'suggest',
+ 'hide_topics' => '',
+ 'hide_series' => '',
+ 'hide_preachers' => '',
+ 'hide_books' => '',
+ 'hide_service_types' => SermonManager::getOption( 'service_type_filtering' ) ? '' : 'yes',
+ );
+ $args = $args + $default;
+
+ $content = wpfc_get_partial( 'content-sermon-filtering', array(
+ 'action' => $action,
+ 'filters' => $filters,
+ 'visibility_mapping' => $visibility_mapping,
+ 'args' => $args,
+ ) );
- ob_start(); ?>
-
- ID, $meta_key, true );
- if ( $data !== '' ) {
+ if ( '' !== $data ) {
return $data;
}
@@ -219,10 +184,10 @@ function get_wpfc_sermon_meta( $meta_key = '' ) {
}
/**
- * Pass sermon content through WordPres functions, to render shortcodes, etc
+ * Pass sermon content through WordPress functions, to render shortcodes, etc.
*
- * @param string $meta_key Sermon meta key
- * @param int $post_id Post ID
+ * @param string $meta_key Sermon meta key.
+ * @param int $post_id Post ID.
*
* @return string The processed content
*/
@@ -241,11 +206,11 @@ function process_wysiwyg_output( $meta_key, $post_id = 0 ) {
}
/**
- * Render sermon description
+ * Render sermon description.
*
- * @param string $before content before description
- * @param string $after content after description
- * @param bool $return True to return, false to echo (default)
+ * @param string $before Content before description.
+ * @param string $after Content after description.
+ * @param bool $return True to return, false to echo (default).
*
* @return string The HTML, if $return is set to true
*/
@@ -260,15 +225,15 @@ function wpfc_sermon_description( $before = '', $after = '', $return = false ) {
}
/**
- * Renders the video player
+ * Renders the video player.
*
- * @param string $url The URL of the video file
- * @param int $seek Allows seeking to specific second in audio file
+ * @param string $url The URL of the video file.
+ * @param int $seek Allows seeking to specific second in audio file.
*
* @since 2.11.0
* @since 2.12.3 added $seek
*
- * @return string Video player HTML
+ * @return string Video player HTML.
*/
function wpfc_render_video( $url = '', $seek = null ) {
if ( ! is_string( $url ) || trim( $url ) === '' ) {
@@ -280,15 +245,15 @@ function wpfc_render_video( $url = '', $seek = null ) {
parse_str( parse_url( $url, PHP_URL_QUERY ), $query );
- return '
';
+ return '
';
}
- $player = \SermonManager::getOption( 'player' ) ?: 'plyr';
+ $player = strtolower( \SermonManager::getOption( 'player' ) ?: 'plyr' );
- if ( $player === 'wordpress' ) {
+ if ( strtolower( 'WordPress' ) === $player ) {
$attr = array(
'src' => $url,
- 'preload' => 'none'
+ 'preload' => 'none',
);
$output = wp_video_shortcode( $attr );
@@ -298,51 +263,62 @@ function wpfc_render_video( $url = '', $seek = null ) {
$is_youtube = $is_youtube_long || $is_youtube_short;
$is_vimeo = strpos( strtolower( $url ), 'vimeo.com' );
$extra_settings = '';
+ $output = '';
if ( is_numeric( $seek ) ) {
- // sanitation just in case
+ // Sanitation just in case.
$extra_settings = 'data-plyr_seek=\'' . intval( $seek ) . '\'';
}
- if ( $player === 'plyr' && ( $is_youtube || $is_vimeo ) ) {
- $output = '
';
+ if ( 'plyr' === $player && ( $is_youtube || $is_vimeo ) ) {
+ $output .= '
';
} else {
- $output = '
';
- $output .= '';
+ $output .= '';
+ $output .= '';
$output .= ' ';
}
}
/**
- * Allows changing of the video player to any HTML
+ * Allows changing of the video player to any HTML.
*
- * @param string $output Video player HTML
- * @param string $url Video source URL
+ * @param string $output Video player HTML.
+ * @param string $url Video source URL.
*/
return apply_filters( 'sm_video_player', $output, $url );
}
/**
- * Renders the audio player
+ * Renders the audio player.
*
- * @param string $url The URL of the audio file
- * @param int $seek Allows seeking to specific second in audio file
+ * @param string|int $source The URL or the attachment ID of the audio file.
+ * @param int $seek Allows seeking to specific second in audio file.
*
* @since 2.12.3 added $seek
*
- * @return string Audio player HTML
+ * @return string Audio player HTML.
*/
-function wpfc_render_audio( $url = '', $seek = null ) {
- if ( ! is_string( $url ) || trim( $url ) === '' ) {
+function wpfc_render_audio( $source = '', $seek = null ) {
+ if ( is_int( $source ) || is_numeric( $source ) ) {
+ $source = wp_get_attachment_url( intval( $source ) );
+
+ if ( ! $source ) {
+ return '';
+ }
+ } elseif ( is_string( $source ) ) {
+ if ( '' === trim( $source ) ) {
+ return '';
+ }
+ } else {
return '';
}
- $player = \SermonManager::getOption( 'player' ) ?: 'plyr';
+ $player = strtolower( \SermonManager::getOption( 'player' ) ?: 'plyr' );
- if ( $player === 'wordpress' ) {
+ if ( strtolower( 'WordPress' ) === $player ) {
$attr = array(
- 'src' => $url,
- 'preload' => 'none'
+ 'src' => $source,
+ 'preload' => 'none',
);
$output = wp_audio_shortcode( $attr );
@@ -350,194 +326,82 @@ function wpfc_render_audio( $url = '', $seek = null ) {
$extra_settings = '';
if ( is_numeric( $seek ) ) {
- // sanitation just in case
+ // Sanitation just in case.
$extra_settings = 'data-plyr_seek=\'' . intval( $seek ) . '\'';
}
- $output = '';
- $output .= '';
+ $output = '';
+
+ $output .= '';
+ $output .= '';
$output .= ' ';
}
/**
- * Allows changing of the audio player to any HTML
+ * Allows changing of the audio player to any HTML.
*
- * @param string $output Audio player HTML
- * @param string $url Audio source URL
+ * @param string $output Audio player HTML.
+ * @param string $source Audio source URL.
*/
- return apply_filters( 'sm_audio_player', $output, $url );
+ return apply_filters( 'sm_audio_player', $output, $source );
}
/**
- * Render sermon attachments HTML
+ * Render sermon attachments HTML.
*
* @return string
*/
function wpfc_sermon_attachments() {
- if ( ! get_wpfc_sermon_meta( 'sermon_notes' ) &&
- ! get_wpfc_sermon_meta( 'sermon_bulletin' ) ) {
+ if ( ! get_wpfc_sermon_meta( 'sermon_notes' ) && ! get_wpfc_sermon_meta( 'sermon_bulletin' ) ) {
return '';
}
- $html = '';
+ $output = wpfc_get_partial( 'content-sermon-attachments' );
- return apply_filters( 'sm_attachments_html', $html );
+ /**
+ * Allows to filter the output of sermon attachments HTML.
+ *
+ * @param string $output The HTML.
+ *
+ * @since 2.11.3
+ */
+ return apply_filters( 'sm_attachments_html', $output );
}
/**
- * Renders updates single sermon view
+ * Renders updates single sermon view.
*
- * @param bool $return True to return output, false to echo (default)
- * @param WP_Post $post WP_Post instance of the sermon
+ * @param bool $return True to return output, false to echo (default).
+ * @param WP_Post $post WP_Post instance of the sermon.
*
- * @return string The HTML if $return is set to true
+ * @return string The HTML if $return is set to true.
*/
function wpfc_sermon_single_v2( $return = false, $post = null ) {
- if ( $post === null ) {
+ if ( null === $post ) {
global $post;
+ } else {
+ // Save global $post value for later restoration. Just in case.
+ $new_post = $post;
+ $old_post = $GLOBALS['post'];
+ $post = $new_post;
}
- ob_start();
- ?>
-
-
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ID ) ) : ?>
-
-
- :
- ID, 'wpfc_sermon_topics' ) ?>
-
-
-
-
-
-
-
-
-
-
>
-
-
-
-
-
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
-
-
-
-
-
-
-
- ID, 'sermon_description', true ); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 'post-thumbnail',
+ );
+ }
+
+ // Get the partial.
+ $output = wpfc_get_partial( 'content-sermon-archive' );
/**
- * Allows you to modify the sermon HTML on archive pages
+ * Allows you to modify the sermon HTML on archive pages.
*
- * @param string $output The HTML that will be outputted
- * @param WP_Post $post The sermon
+ * @param string $output The HTML that will be outputted.
+ * @param WP_Post $post The sermon.
+ * @param array $args Rendering arguments. Passed from shortcode.
*
* @since 2.12.0
*/
- $output = apply_filters( 'wpfc_sermon_excerpt_v2', $output, $post );
+ $output = apply_filters( 'wpfc_sermon_excerpt_v2', $output, $post, $args );
if ( ! $return ) {
echo $output;
@@ -677,26 +448,26 @@ function wpfc_sermon_excerpt_v2( $return = false ) {
}
/**
- * Build fields for element
+ * Build fields for element.
*
- * @param string $taxonomy Taxonomy name
- * @param string $default Force a default value regardless the query var
+ * @param string $taxonomy Taxonomy name.
+ * @param string $default Force a default value regardless the query var.
*
* @return string HTML fields
*
* @since 2.5.0 added $default
*/
function wpfc_get_term_dropdown( $taxonomy, $default = '' ) {
- // reset var
+ // Reset var.
$html = '';
$terms = get_terms( array(
'taxonomy' => $taxonomy,
- 'hide_empty' => false, // todo: add option to disable/enable this globally
+ 'hide_empty' => false, // todo: add option to disable/enable this globally.
) );
- if ( $taxonomy === 'wpfc_bible_book' && \SermonManager::getOption( 'sort_bible_books', true ) ) {
- // book order
+ if ( 'wpfc_bible_book' === $taxonomy && \SermonManager::getOption( 'sort_bible_books', true ) ) {
+ // Book order.
$books = array(
'Genesis',
'Exodus',
@@ -767,9 +538,10 @@ function wpfc_get_term_dropdown( $taxonomy, $default = '' ) {
'Topical',
);
- $ordered_terms = $unordered_terms = array();
+ $ordered_terms = array();
+ $unordered_terms = array();
- // assign every book a number
+ // Assign every book a number.
foreach ( $terms as $term ) {
if ( array_search( $term->name, $books ) !== false ) {
$ordered_terms[ array_search( $term->name, $books ) ] = $term;
@@ -778,15 +550,79 @@ function wpfc_get_term_dropdown( $taxonomy, $default = '' ) {
}
}
- // order the numbers (books)
+ // Order the numbers (books).
ksort( $ordered_terms );
$terms = array_merge( $ordered_terms, $unordered_terms );
}
foreach ( $terms as $term ) {
- $html .= ' slug === get_query_var( $taxonomy ) : $term->slug === $default ) ? 'selected' : '' ) . '>' . $term->name . ' ';
+ $html .= 'slug : $term->slug === $default ) ? 'selected' : '' ) . '>' . $term->name . ' ';
}
return $html;
}
+
+/**
+ * Allows user to override the partial file for rendering by placing it in either:
+ * - `/wp-contents/themes//partials/.php`
+ * - `/wp-contents/themes//template-parts/.php`
+ * - `/wp-contents/themes//.php`
+ *
+ * @param string $name File name of the partial file to load. Can include `.php`, but not required.
+ * @param array $args Array of variable => content, to use in the partial.
+ *
+ * @return string The contents of the partial.
+ *
+ * @since 2.13.0
+ */
+function wpfc_get_partial( $name = '', $args = array() ) {
+ if ( '' === $name ) {
+ $content = '';
+ } else {
+ $partial = null;
+ $GLOBALS['wpfc_partial_args'] = $args;
+
+ if ( false === strpos( $name, '.php' ) ) {
+ $name .= '.php';
+ }
+
+ foreach (
+ array(
+ 'partials/',
+ 'template-parts/',
+ '',
+ ) as $path
+ ) {
+ $partial = locate_template( $path . $name );
+
+ if ( $partial ) {
+ break;
+ }
+ }
+
+ ob_start();
+
+ if ( $partial ) {
+ load_template( $partial, false );
+ } else {
+ if ( file_exists( SM_PATH . 'views/partials/' . $name ) ) {
+ load_template( SM_PATH . 'views/partials/' . $name, false );
+ } else {
+ echo 'Sermon Manager : Failed loading partial "' . str_replace( '.php', '', $name ) . ' ", file does not exist.
';
+ }
+ }
+
+ $content = ob_get_clean();
+ }
+
+ /**
+ * Allows to filter the partial content.
+ *
+ * @param string $content The partial content.
+ * @param string $name The partial file name.
+ *
+ * @since 2.13.0
+ */
+ return apply_filters( 'wpfc_get_partial', $content, $name );
+}
diff --git a/includes/sm-update-functions.php b/includes/sm-update-functions.php
index da5a9e3..f96e655 100644
--- a/includes/sm-update-functions.php
+++ b/includes/sm-update-functions.php
@@ -1,12 +1,15 @@
get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('auto-draft', 'inherit')", 'wpfc_sermon' ) ) as $sermon ) {
- if ( get_post_meta( $sermon->ID, 'sermon_date', true ) === '' &&
- $date = get_post_meta( $sermon->ID, 'sermon_date_old', true ) !== '' ) {
+ $date = get_post_meta( $sermon->ID, 'sermon_date_old', true );
+
+ if ( '' === get_post_meta( $sermon->ID, 'sermon_date', true ) && '' !== $date ) {
update_post_meta( $sermon->ID, 'sermon_date', is_numeric( $date ) ?: strtotime( $date ) );
delete_post_meta( $sermon->ID, 'sermon_date_old' );
}
}
- // clear all cached data
+ // Clear all cached data.
wp_cache_flush();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * Final dates conversion for users who skipped converters in previous SM versions
+ * Final dates conversion for users who skipped converters in previous SM versions.
*
- * Basically, converts "sermon_date" value to Unix time if it's not numeric
+ * Basically, converts "sermon_date" value to Unix time if it's not numeric.
*/
function sm_update_28_convert_dates_to_unix() {
global $wpdb;
- // All sermons
+ // All sermons.
$sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('auto-draft', 'inherit')", 'wpfc_sermon' ) );
foreach ( $sermons as $sermon ) {
- if ( $date = get_post_meta( $sermon->ID, 'sermon_date', true ) ) {
+ $date = get_post_meta( $sermon->ID, 'sermon_date', true );
+
+ if ( $date ) {
if ( ! is_numeric( $date ) ) {
update_post_meta( $sermon->ID, 'sermon_date', strtotime( $date ) );
}
}
}
- // clear all cached data
+ // Clear all cached data.
wp_cache_flush();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
* Fills out dates of sermons that don't have `sermon_date` set. Takes "Published" date for them and marks
- * them as auto-filled, so they get updated when Published date gets updated
+ * them as auto-filled, so they get updated when Published date gets updated.
*/
function sm_update_28_fill_out_empty_dates() {
global $wpdb;
- // All sermons
+ // All sermons.
$sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('auto-draft', 'inherit')", 'wpfc_sermon' ) );
foreach ( $sermons as $sermon ) {
@@ -73,54 +79,54 @@ function sm_update_28_fill_out_empty_dates() {
}
}
- // clear all cached data
+ // Clear all cached data.
wp_cache_flush();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * For enabling sorting by series date
+ * For enabling sorting by series date.
*
* @see SM_Dates_WP::update_series_date()
*/
function sm_update_28_fill_out_series_dates() {
SM_Dates_WP::update_series_date();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * Renders sermon text and saves as "post_content", for better search compatibility
+ * Renders sermon text and saves as "post_content", for better search compatibility.
*
- * @since 2.11.0 updated to render text and not HTML
+ * @since 2.11.0 updated to render text and not HTML.
*/
function sm_update_28_save_sermon_render_into_post_content() {
sm_update_211_render_content();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * We had a bug from 2.8 to 2.8.3, so we will do it again
+ * We had a bug from 2.8 to 2.8.3, so we will do it again.
*/
function sm_update_284_resave_sermons() {
sm_update_28_save_sermon_render_into_post_content();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * There was a bug in function for 2.8, so we will do it again
+ * 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();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
@@ -134,37 +140,38 @@ function sm_update_29_convert_settings() {
add_option( 'sermonmanager_' . $key, $value );
}
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * SB and SE import did not import dates correctly. This function imports them for those who did import
+ * SB and SE import did not import dates correctly. This function imports them for those who did import.
*/
function sm_update_293_fix_import_dates() {
sm_update_28_fill_out_empty_dates();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * Removed Bibly so we will change option names
+ * Removed Bibly so we will change option names.
*/
function sm_update_210_update_options() {
if ( is_bool( SermonManager::getOption( 'bibly' ) ) ) {
add_option( 'sermonmanager_verse_popup', SermonManager::getOption( 'bibly' ) ? 'yes' : 'no' );
}
- if ( $bible_version = SermonManager::getOption( 'bibly_version' ) ) {
+ $bible_version = SermonManager::getOption( 'bibly_version' );
+ if ( $bible_version ) {
add_option( 'sermonmanager_verse_bible_version', $bible_version );
}
if ( is_bool( SermonManager::getOption( 'use_old_player' ) ) ) {
- add_option( 'sermonmanager_player', SermonManager::getOption( 'use_old_player' ) ? 'wordpress' : 'plyr' );
+ add_option( 'sermonmanager_player', SermonManager::getOption( 'use_old_player' ) ? 'tooo' : 'plyr' );
}
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
@@ -174,7 +181,7 @@ function sm_update_210_update_options() {
function sm_update_211_render_content() {
global $wpdb;
- // All sermons
+ // All sermons.
$sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", 'wpfc_sermon' ) );
$sermon_manager = \SermonManager::get_instance();
@@ -183,34 +190,36 @@ function sm_update_211_render_content() {
$sermon_manager->render_sermon_into_content( $sermon->ID, get_post( $sermon->ID ), true );
}
- // clear all cached data
+ // Clear all cached data.
wp_cache_flush();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * Adds time alongside date in sermon date option
+ * Adds time alongside date in sermon date option.
*/
function sm_update_211_update_date_time() {
global $wpdb;
- // All sermons
+ // All sermons.
$sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s", 'wpfc_sermon' ) );
foreach ( $sermons as $sermon ) {
- if ( $sermon_date = get_post_meta( $sermon->ID, 'sermon_date', true ) ) {
+ $sermon_date = get_post_meta( $sermon->ID, 'sermon_date', true );
+
+ if ( $sermon_date ) {
$dt = DateTime::createFromFormat( 'U', $sermon_date );
$dt_post = DateTime::createFromFormat( 'U', mysql2date( 'U', $sermon->post_date ) );
$time = array(
$dt_post->format( 'H' ),
$dt_post->format( 'i' ),
- $dt_post->format( 's' )
+ $dt_post->format( 's' ),
);
- // convert all to ints
+ // Convert all to ints.
$time = array_map( 'intval', $time );
list( $hours, $minutes, $seconds ) = $time;
@@ -224,21 +233,56 @@ function sm_update_211_update_date_time() {
}
}
- // clear all cached data
+ // Clear all cached data.
wp_cache_flush();
- // mark it as done, backup way
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
}
/**
- * There was a bug that prevented preacher slug to be used as a permalink as well
- *
- * Fixed in 2.12.3
+ * There was a bug that prevented preacher slug to be used as a permalink as well.
*/
function sm_update_2123_fix_preacher_permalink() {
flush_rewrite_rules();
- // mark it as done, backup way
+ // Mark it as done, backup way.
+ update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
+}
+
+/**
+ * For enabling sorting by sermon date, in all terms.
+ *
+ * @see SM_Dates_WP::update_term_dates()
+ */
+function sm_update_2130_fill_out_sermon_term_dates() {
+ SM_Dates_WP::update_term_dates();
+
+ // Mark it as done, backup way.
update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
-}
\ No newline at end of file
+}
+
+/**
+ * Removes old auto-generated excerpts
+ */
+function sm_update_2130_remove_excerpts() {
+ $sermons = new WP_Query( array(
+ 'post_type' => 'wpfc_sermon',
+ 'meta_key' => 'sermon_date',
+ 'meta_value_num' => time(),
+ 'meta_compare' => '<=',
+ 'orderby' => 'meta_value_num',
+ 'order' => 'DESC',
+ 'posts_per_page' => - 1,
+ ) );
+
+ foreach ( $sermons->posts as $sermon ) {
+ wp_update_post( array(
+ 'ID' => $sermon->ID,
+ 'post_excerpt' => '',
+ ) );
+ }
+
+ // Mark it as done, backup way.
+ update_option( 'wp_sm_updater_' . __FUNCTION__ . '_done', 1 );
+}
diff --git a/includes/CMB2/bootstrap.php b/includes/vendor/CMB2/bootstrap.php
similarity index 100%
rename from includes/CMB2/bootstrap.php
rename to includes/vendor/CMB2/bootstrap.php
diff --git a/includes/CMB2/css/cmb2-display-rtl.css b/includes/vendor/CMB2/css/cmb2-display-rtl.css
similarity index 100%
rename from includes/CMB2/css/cmb2-display-rtl.css
rename to includes/vendor/CMB2/css/cmb2-display-rtl.css
diff --git a/includes/CMB2/css/cmb2-display-rtl.min.css b/includes/vendor/CMB2/css/cmb2-display-rtl.min.css
similarity index 100%
rename from includes/CMB2/css/cmb2-display-rtl.min.css
rename to includes/vendor/CMB2/css/cmb2-display-rtl.min.css
diff --git a/includes/CMB2/css/cmb2-display.css b/includes/vendor/CMB2/css/cmb2-display.css
similarity index 100%
rename from includes/CMB2/css/cmb2-display.css
rename to includes/vendor/CMB2/css/cmb2-display.css
diff --git a/includes/CMB2/css/cmb2-display.css.map b/includes/vendor/CMB2/css/cmb2-display.css.map
similarity index 100%
rename from includes/CMB2/css/cmb2-display.css.map
rename to includes/vendor/CMB2/css/cmb2-display.css.map
diff --git a/includes/CMB2/css/cmb2-display.min.css b/includes/vendor/CMB2/css/cmb2-display.min.css
similarity index 100%
rename from includes/CMB2/css/cmb2-display.min.css
rename to includes/vendor/CMB2/css/cmb2-display.min.css
diff --git a/includes/CMB2/css/cmb2-front-rtl.css b/includes/vendor/CMB2/css/cmb2-front-rtl.css
similarity index 100%
rename from includes/CMB2/css/cmb2-front-rtl.css
rename to includes/vendor/CMB2/css/cmb2-front-rtl.css
diff --git a/includes/CMB2/css/cmb2-front-rtl.min.css b/includes/vendor/CMB2/css/cmb2-front-rtl.min.css
similarity index 100%
rename from includes/CMB2/css/cmb2-front-rtl.min.css
rename to includes/vendor/CMB2/css/cmb2-front-rtl.min.css
diff --git a/includes/CMB2/css/cmb2-front.css b/includes/vendor/CMB2/css/cmb2-front.css
similarity index 100%
rename from includes/CMB2/css/cmb2-front.css
rename to includes/vendor/CMB2/css/cmb2-front.css
diff --git a/includes/CMB2/css/cmb2-front.css.map b/includes/vendor/CMB2/css/cmb2-front.css.map
similarity index 100%
rename from includes/CMB2/css/cmb2-front.css.map
rename to includes/vendor/CMB2/css/cmb2-front.css.map
diff --git a/includes/CMB2/css/cmb2-front.min.css b/includes/vendor/CMB2/css/cmb2-front.min.css
similarity index 100%
rename from includes/CMB2/css/cmb2-front.min.css
rename to includes/vendor/CMB2/css/cmb2-front.min.css
diff --git a/includes/CMB2/css/cmb2-rtl.css b/includes/vendor/CMB2/css/cmb2-rtl.css
similarity index 100%
rename from includes/CMB2/css/cmb2-rtl.css
rename to includes/vendor/CMB2/css/cmb2-rtl.css
diff --git a/includes/CMB2/css/cmb2-rtl.min.css b/includes/vendor/CMB2/css/cmb2-rtl.min.css
similarity index 100%
rename from includes/CMB2/css/cmb2-rtl.min.css
rename to includes/vendor/CMB2/css/cmb2-rtl.min.css
diff --git a/includes/CMB2/css/cmb2.css b/includes/vendor/CMB2/css/cmb2.css
similarity index 100%
rename from includes/CMB2/css/cmb2.css
rename to includes/vendor/CMB2/css/cmb2.css
diff --git a/includes/CMB2/css/cmb2.css.map b/includes/vendor/CMB2/css/cmb2.css.map
similarity index 100%
rename from includes/CMB2/css/cmb2.css.map
rename to includes/vendor/CMB2/css/cmb2.css.map
diff --git a/includes/CMB2/css/cmb2.min.css b/includes/vendor/CMB2/css/cmb2.min.css
similarity index 100%
rename from includes/CMB2/css/cmb2.min.css
rename to includes/vendor/CMB2/css/cmb2.min.css
diff --git a/includes/CMB2/css/index.php b/includes/vendor/CMB2/css/index.php
similarity index 100%
rename from includes/CMB2/css/index.php
rename to includes/vendor/CMB2/css/index.php
diff --git a/includes/CMB2/css/sass/cmb2-display.scss b/includes/vendor/CMB2/css/sass/cmb2-display.scss
similarity index 100%
rename from includes/CMB2/css/sass/cmb2-display.scss
rename to includes/vendor/CMB2/css/sass/cmb2-display.scss
diff --git a/includes/CMB2/css/sass/cmb2-front.scss b/includes/vendor/CMB2/css/sass/cmb2-front.scss
similarity index 100%
rename from includes/CMB2/css/sass/cmb2-front.scss
rename to includes/vendor/CMB2/css/sass/cmb2-front.scss
diff --git a/includes/CMB2/css/sass/cmb2.scss b/includes/vendor/CMB2/css/sass/cmb2.scss
similarity index 100%
rename from includes/CMB2/css/sass/cmb2.scss
rename to includes/vendor/CMB2/css/sass/cmb2.scss
diff --git a/includes/CMB2/css/sass/index.php b/includes/vendor/CMB2/css/sass/index.php
similarity index 100%
rename from includes/CMB2/css/sass/index.php
rename to includes/vendor/CMB2/css/sass/index.php
diff --git a/includes/CMB2/css/sass/partials/_collapsible_ui.scss b/includes/vendor/CMB2/css/sass/partials/_collapsible_ui.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_collapsible_ui.scss
rename to includes/vendor/CMB2/css/sass/partials/_collapsible_ui.scss
diff --git a/includes/CMB2/css/sass/partials/_display.scss b/includes/vendor/CMB2/css/sass/partials/_display.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_display.scss
rename to includes/vendor/CMB2/css/sass/partials/_display.scss
diff --git a/includes/CMB2/css/sass/partials/_front.scss b/includes/vendor/CMB2/css/sass/partials/_front.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_front.scss
rename to includes/vendor/CMB2/css/sass/partials/_front.scss
diff --git a/includes/CMB2/css/sass/partials/_jquery_ui.scss b/includes/vendor/CMB2/css/sass/partials/_jquery_ui.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_jquery_ui.scss
rename to includes/vendor/CMB2/css/sass/partials/_jquery_ui.scss
diff --git a/includes/CMB2/css/sass/partials/_main_wrap.scss b/includes/vendor/CMB2/css/sass/partials/_main_wrap.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_main_wrap.scss
rename to includes/vendor/CMB2/css/sass/partials/_main_wrap.scss
diff --git a/includes/CMB2/css/sass/partials/_misc.scss b/includes/vendor/CMB2/css/sass/partials/_misc.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_misc.scss
rename to includes/vendor/CMB2/css/sass/partials/_misc.scss
diff --git a/includes/CMB2/css/sass/partials/_mixins.scss b/includes/vendor/CMB2/css/sass/partials/_mixins.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_mixins.scss
rename to includes/vendor/CMB2/css/sass/partials/_mixins.scss
diff --git a/includes/CMB2/css/sass/partials/_post_metaboxes.scss b/includes/vendor/CMB2/css/sass/partials/_post_metaboxes.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_post_metaboxes.scss
rename to includes/vendor/CMB2/css/sass/partials/_post_metaboxes.scss
diff --git a/includes/CMB2/css/sass/partials/_sidebar_placements.scss b/includes/vendor/CMB2/css/sass/partials/_sidebar_placements.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_sidebar_placements.scss
rename to includes/vendor/CMB2/css/sass/partials/_sidebar_placements.scss
diff --git a/includes/CMB2/css/sass/partials/_variables.scss b/includes/vendor/CMB2/css/sass/partials/_variables.scss
similarity index 100%
rename from includes/CMB2/css/sass/partials/_variables.scss
rename to includes/vendor/CMB2/css/sass/partials/_variables.scss
diff --git a/includes/CMB2/css/sass/partials/index.php b/includes/vendor/CMB2/css/sass/partials/index.php
similarity index 100%
rename from includes/CMB2/css/sass/partials/index.php
rename to includes/vendor/CMB2/css/sass/partials/index.php
diff --git a/includes/CMB2/images/ico-delete.png b/includes/vendor/CMB2/images/ico-delete.png
similarity index 100%
rename from includes/CMB2/images/ico-delete.png
rename to includes/vendor/CMB2/images/ico-delete.png
diff --git a/includes/CMB2/images/index.php b/includes/vendor/CMB2/images/index.php
similarity index 100%
rename from includes/CMB2/images/index.php
rename to includes/vendor/CMB2/images/index.php
diff --git a/includes/CMB2/images/ui-bg_flat_0_aaaaaa_40x100.png b/includes/vendor/CMB2/images/ui-bg_flat_0_aaaaaa_40x100.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_flat_0_aaaaaa_40x100.png
rename to includes/vendor/CMB2/images/ui-bg_flat_0_aaaaaa_40x100.png
diff --git a/includes/CMB2/images/ui-bg_flat_75_ffffff_40x100.png b/includes/vendor/CMB2/images/ui-bg_flat_75_ffffff_40x100.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_flat_75_ffffff_40x100.png
rename to includes/vendor/CMB2/images/ui-bg_flat_75_ffffff_40x100.png
diff --git a/includes/CMB2/images/ui-bg_glass_55_fbf9ee_1x400.png b/includes/vendor/CMB2/images/ui-bg_glass_55_fbf9ee_1x400.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_glass_55_fbf9ee_1x400.png
rename to includes/vendor/CMB2/images/ui-bg_glass_55_fbf9ee_1x400.png
diff --git a/includes/CMB2/images/ui-bg_glass_65_ffffff_1x400.png b/includes/vendor/CMB2/images/ui-bg_glass_65_ffffff_1x400.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_glass_65_ffffff_1x400.png
rename to includes/vendor/CMB2/images/ui-bg_glass_65_ffffff_1x400.png
diff --git a/includes/CMB2/images/ui-bg_glass_75_dadada_1x400.png b/includes/vendor/CMB2/images/ui-bg_glass_75_dadada_1x400.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_glass_75_dadada_1x400.png
rename to includes/vendor/CMB2/images/ui-bg_glass_75_dadada_1x400.png
diff --git a/includes/CMB2/images/ui-bg_glass_75_e6e6e6_1x400.png b/includes/vendor/CMB2/images/ui-bg_glass_75_e6e6e6_1x400.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_glass_75_e6e6e6_1x400.png
rename to includes/vendor/CMB2/images/ui-bg_glass_75_e6e6e6_1x400.png
diff --git a/includes/CMB2/images/ui-bg_glass_95_fef1ec_1x400.png b/includes/vendor/CMB2/images/ui-bg_glass_95_fef1ec_1x400.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_glass_95_fef1ec_1x400.png
rename to includes/vendor/CMB2/images/ui-bg_glass_95_fef1ec_1x400.png
diff --git a/includes/CMB2/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/includes/vendor/CMB2/images/ui-bg_highlight-soft_75_cccccc_1x100.png
similarity index 100%
rename from includes/CMB2/images/ui-bg_highlight-soft_75_cccccc_1x100.png
rename to includes/vendor/CMB2/images/ui-bg_highlight-soft_75_cccccc_1x100.png
diff --git a/includes/CMB2/images/ui-icons_222222_256x240.png b/includes/vendor/CMB2/images/ui-icons_222222_256x240.png
similarity index 100%
rename from includes/CMB2/images/ui-icons_222222_256x240.png
rename to includes/vendor/CMB2/images/ui-icons_222222_256x240.png
diff --git a/includes/CMB2/images/ui-icons_2e83ff_256x240.png b/includes/vendor/CMB2/images/ui-icons_2e83ff_256x240.png
similarity index 100%
rename from includes/CMB2/images/ui-icons_2e83ff_256x240.png
rename to includes/vendor/CMB2/images/ui-icons_2e83ff_256x240.png
diff --git a/includes/CMB2/images/ui-icons_454545_256x240.png b/includes/vendor/CMB2/images/ui-icons_454545_256x240.png
similarity index 100%
rename from includes/CMB2/images/ui-icons_454545_256x240.png
rename to includes/vendor/CMB2/images/ui-icons_454545_256x240.png
diff --git a/includes/CMB2/images/ui-icons_888888_256x240.png b/includes/vendor/CMB2/images/ui-icons_888888_256x240.png
similarity index 100%
rename from includes/CMB2/images/ui-icons_888888_256x240.png
rename to includes/vendor/CMB2/images/ui-icons_888888_256x240.png
diff --git a/includes/CMB2/images/ui-icons_cd0a0a_256x240.png b/includes/vendor/CMB2/images/ui-icons_cd0a0a_256x240.png
similarity index 100%
rename from includes/CMB2/images/ui-icons_cd0a0a_256x240.png
rename to includes/vendor/CMB2/images/ui-icons_cd0a0a_256x240.png
diff --git a/includes/CMB2/includes/CMB2.php b/includes/vendor/CMB2/includes/CMB2.php
similarity index 100%
rename from includes/CMB2/includes/CMB2.php
rename to includes/vendor/CMB2/includes/CMB2.php
diff --git a/includes/CMB2/includes/CMB2_Ajax.php b/includes/vendor/CMB2/includes/CMB2_Ajax.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Ajax.php
rename to includes/vendor/CMB2/includes/CMB2_Ajax.php
diff --git a/includes/CMB2/includes/CMB2_Base.php b/includes/vendor/CMB2/includes/CMB2_Base.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Base.php
rename to includes/vendor/CMB2/includes/CMB2_Base.php
diff --git a/includes/CMB2/includes/CMB2_Boxes.php b/includes/vendor/CMB2/includes/CMB2_Boxes.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Boxes.php
rename to includes/vendor/CMB2/includes/CMB2_Boxes.php
diff --git a/includes/CMB2/includes/CMB2_Field.php b/includes/vendor/CMB2/includes/CMB2_Field.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Field.php
rename to includes/vendor/CMB2/includes/CMB2_Field.php
diff --git a/includes/CMB2/includes/CMB2_Field_Display.php b/includes/vendor/CMB2/includes/CMB2_Field_Display.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Field_Display.php
rename to includes/vendor/CMB2/includes/CMB2_Field_Display.php
diff --git a/includes/CMB2/includes/CMB2_Hookup_Base.php b/includes/vendor/CMB2/includes/CMB2_Hookup_Base.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Hookup_Base.php
rename to includes/vendor/CMB2/includes/CMB2_Hookup_Base.php
diff --git a/includes/CMB2/includes/CMB2_JS.php b/includes/vendor/CMB2/includes/CMB2_JS.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_JS.php
rename to includes/vendor/CMB2/includes/CMB2_JS.php
diff --git a/includes/CMB2/includes/CMB2_Options.php b/includes/vendor/CMB2/includes/CMB2_Options.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Options.php
rename to includes/vendor/CMB2/includes/CMB2_Options.php
diff --git a/includes/CMB2/includes/CMB2_Sanitize.php b/includes/vendor/CMB2/includes/CMB2_Sanitize.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Sanitize.php
rename to includes/vendor/CMB2/includes/CMB2_Sanitize.php
diff --git a/includes/CMB2/includes/CMB2_Show_Filters.php b/includes/vendor/CMB2/includes/CMB2_Show_Filters.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Show_Filters.php
rename to includes/vendor/CMB2/includes/CMB2_Show_Filters.php
diff --git a/includes/CMB2/includes/CMB2_Types.php b/includes/vendor/CMB2/includes/CMB2_Types.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_Types.php
rename to includes/vendor/CMB2/includes/CMB2_Types.php
diff --git a/includes/CMB2/includes/CMB2_Utils.php b/includes/vendor/CMB2/includes/CMB2_Utils.php
similarity index 99%
rename from includes/CMB2/includes/CMB2_Utils.php
rename to includes/vendor/CMB2/includes/CMB2_Utils.php
index fd2fa1d..d34f4e0 100755
--- a/includes/CMB2/includes/CMB2_Utils.php
+++ b/includes/vendor/CMB2/includes/CMB2_Utils.php
@@ -260,7 +260,7 @@ public static function array_insert( &$array, $new, $position ) {
*/
public static function url( $path = '' ) {
// SM: Seems like CMB2 doesn't return a correct URL. This should fix it.
- return str_replace( site_url(), '', SM_URL ) . 'includes/CMB2/' . $path;
+ return str_replace( site_url(), '', SM_URL ) . 'includes/vendor/CMB2/' . $path;
if ( self::$url ) {
return self::$url . $path;
diff --git a/includes/CMB2/includes/CMB2_hookup.php b/includes/vendor/CMB2/includes/CMB2_hookup.php
similarity index 100%
rename from includes/CMB2/includes/CMB2_hookup.php
rename to includes/vendor/CMB2/includes/CMB2_hookup.php
diff --git a/includes/CMB2/includes/helper-functions.php b/includes/vendor/CMB2/includes/helper-functions.php
similarity index 100%
rename from includes/CMB2/includes/helper-functions.php
rename to includes/vendor/CMB2/includes/helper-functions.php
diff --git a/includes/CMB2/includes/index.php b/includes/vendor/CMB2/includes/index.php
similarity index 100%
rename from includes/CMB2/includes/index.php
rename to includes/vendor/CMB2/includes/index.php
diff --git a/includes/CMB2/includes/rest-api/CMB2_REST.php b/includes/vendor/CMB2/includes/rest-api/CMB2_REST.php
similarity index 100%
rename from includes/CMB2/includes/rest-api/CMB2_REST.php
rename to includes/vendor/CMB2/includes/rest-api/CMB2_REST.php
diff --git a/includes/CMB2/includes/rest-api/CMB2_REST_Controller.php b/includes/vendor/CMB2/includes/rest-api/CMB2_REST_Controller.php
similarity index 100%
rename from includes/CMB2/includes/rest-api/CMB2_REST_Controller.php
rename to includes/vendor/CMB2/includes/rest-api/CMB2_REST_Controller.php
diff --git a/includes/CMB2/includes/rest-api/CMB2_REST_Controller_Boxes.php b/includes/vendor/CMB2/includes/rest-api/CMB2_REST_Controller_Boxes.php
similarity index 100%
rename from includes/CMB2/includes/rest-api/CMB2_REST_Controller_Boxes.php
rename to includes/vendor/CMB2/includes/rest-api/CMB2_REST_Controller_Boxes.php
diff --git a/includes/CMB2/includes/rest-api/CMB2_REST_Controller_Fields.php b/includes/vendor/CMB2/includes/rest-api/CMB2_REST_Controller_Fields.php
similarity index 100%
rename from includes/CMB2/includes/rest-api/CMB2_REST_Controller_Fields.php
rename to includes/vendor/CMB2/includes/rest-api/CMB2_REST_Controller_Fields.php
diff --git a/includes/CMB2/includes/shim/WP_REST_Controller.php b/includes/vendor/CMB2/includes/shim/WP_REST_Controller.php
similarity index 100%
rename from includes/CMB2/includes/shim/WP_REST_Controller.php
rename to includes/vendor/CMB2/includes/shim/WP_REST_Controller.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Base.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Base.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Base.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Base.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Checkbox.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Checkbox.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Checkbox.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Checkbox.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Colorpicker.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Colorpicker.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Colorpicker.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Colorpicker.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_File.php b/includes/vendor/CMB2/includes/types/CMB2_Type_File.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_File.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_File.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_File_Base.php b/includes/vendor/CMB2/includes/types/CMB2_Type_File_Base.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_File_Base.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_File_Base.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_File_List.php b/includes/vendor/CMB2/includes/types/CMB2_Type_File_List.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_File_List.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_File_List.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Multi_Base.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Multi_Base.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Multi_Base.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Multi_Base.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Multicheck.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Multicheck.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Multicheck.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Multicheck.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Oembed.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Oembed.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Oembed.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Oembed.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Picker_Base.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Picker_Base.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Picker_Base.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Picker_Base.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Radio.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Radio.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Radio.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Radio.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Select.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Select.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Select.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Select.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Select_Timezone.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Select_Timezone.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Select_Timezone.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Select_Timezone.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Taxonomy_Base.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Base.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Taxonomy_Base.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Base.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Taxonomy_Multicheck.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Multicheck.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Taxonomy_Multicheck.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Multicheck.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Taxonomy_Radio.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Radio.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Taxonomy_Radio.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Radio.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Taxonomy_Select.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Select.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Taxonomy_Select.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Taxonomy_Select.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Text.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Text.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Text.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Text.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Text_Date.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Date.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Text_Date.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Text_Date.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp_Timezone.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp_Timezone.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp_Timezone.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Text_Datetime_Timestamp_Timezone.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Text_Time.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Time.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Text_Time.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Text_Time.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Textarea.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Textarea.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Textarea.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Textarea.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Textarea_Code.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Textarea_Code.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Textarea_Code.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Textarea_Code.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Title.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Title.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Title.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Title.php
diff --git a/includes/CMB2/includes/types/CMB2_Type_Wysiwyg.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Wysiwyg.php
similarity index 100%
rename from includes/CMB2/includes/types/CMB2_Type_Wysiwyg.php
rename to includes/vendor/CMB2/includes/types/CMB2_Type_Wysiwyg.php
diff --git a/includes/CMB2/index.php b/includes/vendor/CMB2/index.php
similarity index 100%
rename from includes/CMB2/index.php
rename to includes/vendor/CMB2/index.php
diff --git a/includes/CMB2/init.php b/includes/vendor/CMB2/init.php
similarity index 96%
rename from includes/CMB2/init.php
rename to includes/vendor/CMB2/init.php
index 0b641e9..b3c1177 100755
--- a/includes/CMB2/init.php
+++ b/includes/vendor/CMB2/init.php
@@ -145,15 +145,15 @@ public function include_cmb() {
$this->l10ni18n();
// Include helper functions
- require_once 'includes/CMB2_Base.php';
- require_once 'includes/CMB2.php';
- require_once 'includes/helper-functions.php';
+ require_once __DIR__ . '/includes/CMB2_Base.php';
+ require_once __DIR__ . '/includes/CMB2.php';
+ require_once __DIR__ . '/includes/helper-functions.php';
// Now kick off the class autoloader
spl_autoload_register( 'cmb2_autoload_classes' );
// Kick the whole thing off
- require_once 'bootstrap.php';
+ require_once __DIR__ . '/bootstrap.php';
if ( function_exists( 'cmb2_bootstrap' ) ) {
cmb2_bootstrap();
}
diff --git a/includes/CMB2/js/cmb2-wysiwyg.js b/includes/vendor/CMB2/js/cmb2-wysiwyg.js
similarity index 100%
rename from includes/CMB2/js/cmb2-wysiwyg.js
rename to includes/vendor/CMB2/js/cmb2-wysiwyg.js
diff --git a/includes/CMB2/js/cmb2.js b/includes/vendor/CMB2/js/cmb2.js
similarity index 100%
rename from includes/CMB2/js/cmb2.js
rename to includes/vendor/CMB2/js/cmb2.js
diff --git a/includes/CMB2/js/cmb2.min.js b/includes/vendor/CMB2/js/cmb2.min.js
similarity index 100%
rename from includes/CMB2/js/cmb2.min.js
rename to includes/vendor/CMB2/js/cmb2.min.js
diff --git a/includes/CMB2/js/index.php b/includes/vendor/CMB2/js/index.php
similarity index 100%
rename from includes/CMB2/js/index.php
rename to includes/vendor/CMB2/js/index.php
diff --git a/includes/CMB2/js/jquery-ui-timepicker-addon.min.js b/includes/vendor/CMB2/js/jquery-ui-timepicker-addon.min.js
similarity index 100%
rename from includes/CMB2/js/jquery-ui-timepicker-addon.min.js
rename to includes/vendor/CMB2/js/jquery-ui-timepicker-addon.min.js
diff --git a/includes/CMB2/readme.txt b/includes/vendor/CMB2/readme.txt
similarity index 100%
rename from includes/CMB2/readme.txt
rename to includes/vendor/CMB2/readme.txt
diff --git a/includes/entry-views.php b/includes/vendor/entry-views.php
similarity index 97%
rename from includes/entry-views.php
rename to includes/vendor/entry-views.php
index ae27264..3478783 100755
--- a/includes/entry-views.php
+++ b/includes/vendor/entry-views.php
@@ -1,150 +1,150 @@
-get_queried_object();
- /* Check if the post type supports the 'entry-views' feature. */
- if ( post_type_supports( $post->post_type, 'entry-views' ) ) {
- if ( empty( $wpfc_entry_views ) ) {
- $wpfc_entry_views = new stdClass();
- }
- /* Set the post ID for later use because we wouldn't want a custom query to change this. */
- $wpfc_entry_views->post_id = $post->ID;
- /* Enqueue the jQuery library. */
- wp_enqueue_script( 'jquery' );
- /* Load the entry views JavaScript in the footer. */
- add_action( 'wp_footer', 'wpfc_entry_views_load_scripts' );
- }
- }
-}
-
-/**
- * Updates the number of views when on a singular view of a post. This function uses post meta to store
- * the number of views per post. By default, the meta key is 'Views', but you can filter this with the
- * 'wpfc_entry_views_meta_key' hook.
- *
- * @since 0.1
- */
-function wpfc_entry_views_update( $post_id = '' ) {
- global $wp_query;
- /* If we're on a singular view of a post, calculate the number of views. */
- if ( ! empty( $post_id ) ) {
- /* Allow devs to override the meta key used. By default, this is 'Views'. */
- $meta_key = apply_filters( 'wpfc_entry_views_meta_key', 'Views' );
- /* Get the number of views the post currently has. */
- $old_views = get_post_meta( $post_id, $meta_key, true );
- /* Add +1 to the number of current views. */
- $new_views = absint( $old_views ) + 1;
- /* Update the view count with the new view count. */
- update_post_meta( $post_id, $meta_key, $new_views, $old_views );
- }
-}
-
-/**
- * Gets the number of views a specific post has. It also doubles as a shortcode, which is called with the
- * [entry-views] format.
- *
- * @since 0.1
- *
- * @param array $attr Attributes for use in the shortcode.
- */
-function wpfc_entry_views_get( $attr = '' ) {
- global $post;
- /* Merge the defaults and the given attributes. */
- $attr = shortcode_atts( array( 'before' => '', 'after' => '', 'post_id' => $post->ID ), $attr );
- /* Allow devs to override the meta key used. */
- $meta_key = apply_filters( 'wpfc_entry_views_meta_key', 'Views' );
- /* Get the number of views the post has. */
- $views = intval( get_post_meta( $attr['post_id'], $meta_key, true ) );
-
- /* Returns the formatted number of views. */
-
- return $attr['before'] . number_format_i18n( $views ) . $attr['after'];
-}
-
-/**
- * Callback function hooked to 'wp_ajax_wpfc_entry_views' and 'wp_ajax_nopriv_wpfc_entry_views'. It checks the
- * AJAX nonce and passes the given $post_id to the entry views update function.
- *
- * @since 0.1
- */
-function wpfc_entry_views_update_ajax() {
- /* Check the AJAX nonce to make sure this is a valid request. */
- check_ajax_referer( 'wpfc_entry_views_ajax' );
- /* If the post ID is set, set it to the $post_id variable and make sure it's an integer. */
- if ( isset( $_POST['post_id'] ) ) {
- $post_id = absint( $_POST['post_id'] );
- }
- /* If $post_id isn't empty, pass it to the wpfc_entry_views_update() function to update the view count. */
- if ( ! empty( $post_id ) ) {
- wpfc_entry_views_update( $post_id );
- }
-}
-
-/**
- * Displays a small script that sends an AJAX request for the page. It passes the $post_id to the AJAX
- * callback function for updating the meta.
- *
- * @since 0.1
- */
-function wpfc_entry_views_load_scripts() {
- global $wpfc_entry_views;
- /* Create a nonce for the AJAX request. */
- $nonce = wp_create_nonce( 'wpfc_entry_views_ajax' );
- /* Display the JavaScript needed. */
- echo '' . "\n";
-}
-
-?>
+get_queried_object();
+ /* Check if the post type supports the 'entry-views' feature. */
+ if ( post_type_supports( $post->post_type, 'entry-views' ) ) {
+ if ( empty( $wpfc_entry_views ) ) {
+ $wpfc_entry_views = new stdClass();
+ }
+ /* Set the post ID for later use because we wouldn't want a custom query to change this. */
+ $wpfc_entry_views->post_id = $post->ID;
+ /* Enqueue the jQuery library. */
+ wp_enqueue_script( 'jquery' );
+ /* Load the entry views JavaScript in the footer. */
+ add_action( 'wp_footer', 'wpfc_entry_views_load_scripts' );
+ }
+ }
+}
+
+/**
+ * Updates the number of views when on a singular view of a post. This function uses post meta to store
+ * the number of views per post. By default, the meta key is 'Views', but you can filter this with the
+ * 'wpfc_entry_views_meta_key' hook.
+ *
+ * @since 0.1
+ */
+function wpfc_entry_views_update( $post_id = '' ) {
+ global $wp_query;
+ /* If we're on a singular view of a post, calculate the number of views. */
+ if ( ! empty( $post_id ) ) {
+ /* Allow devs to override the meta key used. By default, this is 'Views'. */
+ $meta_key = apply_filters( 'wpfc_entry_views_meta_key', 'Views' );
+ /* Get the number of views the post currently has. */
+ $old_views = get_post_meta( $post_id, $meta_key, true );
+ /* Add +1 to the number of current views. */
+ $new_views = absint( $old_views ) + 1;
+ /* Update the view count with the new view count. */
+ update_post_meta( $post_id, $meta_key, $new_views, $old_views );
+ }
+}
+
+/**
+ * Gets the number of views a specific post has. It also doubles as a shortcode, which is called with the
+ * [entry-views] format.
+ *
+ * @since 0.1
+ *
+ * @param array $attr Attributes for use in the shortcode.
+ */
+function wpfc_entry_views_get( $attr = '' ) {
+ global $post;
+ /* Merge the defaults and the given attributes. */
+ $attr = shortcode_atts( array( 'before' => '', 'after' => '', 'post_id' => $post->ID ), $attr );
+ /* Allow devs to override the meta key used. */
+ $meta_key = apply_filters( 'wpfc_entry_views_meta_key', 'Views' );
+ /* Get the number of views the post has. */
+ $views = intval( get_post_meta( $attr['post_id'], $meta_key, true ) );
+
+ /* Returns the formatted number of views. */
+
+ return $attr['before'] . number_format_i18n( $views ) . $attr['after'];
+}
+
+/**
+ * Callback function hooked to 'wp_ajax_wpfc_entry_views' and 'wp_ajax_nopriv_wpfc_entry_views'. It checks the
+ * AJAX nonce and passes the given $post_id to the entry views update function.
+ *
+ * @since 0.1
+ */
+function wpfc_entry_views_update_ajax() {
+ /* Check the AJAX nonce to make sure this is a valid request. */
+ check_ajax_referer( 'wpfc_entry_views_ajax' );
+ /* If the post ID is set, set it to the $post_id variable and make sure it's an integer. */
+ if ( isset( $_POST['post_id'] ) ) {
+ $post_id = absint( $_POST['post_id'] );
+ }
+ /* If $post_id isn't empty, pass it to the wpfc_entry_views_update() function to update the view count. */
+ if ( ! empty( $post_id ) ) {
+ wpfc_entry_views_update( $post_id );
+ }
+}
+
+/**
+ * Displays a small script that sends an AJAX request for the page. It passes the $post_id to the AJAX
+ * callback function for updating the meta.
+ *
+ * @since 0.1
+ */
+function wpfc_entry_views_load_scripts() {
+ global $wpfc_entry_views;
+ /* Create a nonce for the AJAX request. */
+ $nonce = wp_create_nonce( 'wpfc_entry_views_ajax' );
+ /* Display the JavaScript needed. */
+ echo '' . "\n";
+}
+
+?>
diff --git a/includes/taxonomy-images/blank.png b/includes/vendor/taxonomy-images/blank.png
similarity index 100%
rename from includes/taxonomy-images/blank.png
rename to includes/vendor/taxonomy-images/blank.png
diff --git a/includes/taxonomy-images/controls.png b/includes/vendor/taxonomy-images/controls.png
similarity index 100%
rename from includes/taxonomy-images/controls.png
rename to includes/vendor/taxonomy-images/controls.png
diff --git a/includes/taxonomy-images/css/admin.css b/includes/vendor/taxonomy-images/css/admin.css
similarity index 94%
rename from includes/taxonomy-images/css/admin.css
rename to includes/vendor/taxonomy-images/css/admin.css
index 8b2e11a..f7a652d 100755
--- a/includes/taxonomy-images/css/admin.css
+++ b/includes/vendor/taxonomy-images/css/admin.css
@@ -1,78 +1,78 @@
-td.sermon-image-plugin-button {
- display: none;
-}
-
-.sermon-images-modal td.sermon-image-plugin-button {
- display: block !important;
-}
-
-.sermon-images-modal .create-association .term-name {
- font-style: italic;
-}
-
-.sermon-images-modal .create-association {
- display: inline;
-}
-
-.sermon-images-modal .remove-association {
- display: none;
- color: #bc0b0b;
- text-decoration: underline;
- cursor: pointer;
-}
-
-.sermon-images-modal #tab-type_url,
-.sermon-images-modal .savesend input {
- display: none !important;
-}
-
-.sermon-image-thumbnail {
- display: block;
- height: 77px;
- width: 77px;
- overflow: hidden;
- text-align: center;
- margin-bottom: 3px;
-}
-
-.sermon-image-control .control {
- display: block;
- float: left;
- text-indent: -9999em;
- width: 15px;
- height: 15px;
- background: url(controls.png);
- background-repeat: no-repeat;
-}
-
-.sermon-image-control .control:hover {
- cursor: pointer;
-}
-
-.sermon-image-control .upload {
- background-position: 0 0;
-}
-
-.sermon-image-control .upload:hover {
- background-position: -15px 0
-}
-
-.sermon-image-control .remove {
- background-position: -30px 0;
-}
-
-.sermon-image-control .remove:hover {
- background-position: -45px 0;
-}
-
-.sermon-image-control .library {
- background-position: -60px 0;
-}
-
-.sermon-image-control .hide {
- visibility: hidden;
-}
-
-.sermon-image-control .show {
- visibility: visible;
-}
+td.sermon-image-plugin-button {
+ display: none;
+}
+
+.sermon-images-modal td.sermon-image-plugin-button {
+ display: block !important;
+}
+
+.sermon-images-modal .create-association .term-name {
+ font-style: italic;
+}
+
+.sermon-images-modal .create-association {
+ display: inline;
+}
+
+.sermon-images-modal .remove-association {
+ display: none;
+ color: #bc0b0b;
+ text-decoration: underline;
+ cursor: pointer;
+}
+
+.sermon-images-modal #tab-type_url,
+.sermon-images-modal .savesend input {
+ display: none !important;
+}
+
+.sermon-image-thumbnail {
+ display: block;
+ height: 77px;
+ width: 77px;
+ overflow: hidden;
+ text-align: center;
+ margin-bottom: 3px;
+}
+
+.sermon-image-control .control {
+ display: block;
+ float: left;
+ text-indent: -9999em;
+ width: 15px;
+ height: 15px;
+ background: url(controls.png);
+ background-repeat: no-repeat;
+}
+
+.sermon-image-control .control:hover {
+ cursor: pointer;
+}
+
+.sermon-image-control .upload {
+ background-position: 0 0;
+}
+
+.sermon-image-control .upload:hover {
+ background-position: -15px 0
+}
+
+.sermon-image-control .remove {
+ background-position: -30px 0;
+}
+
+.sermon-image-control .remove:hover {
+ background-position: -45px 0;
+}
+
+.sermon-image-control .library {
+ background-position: -60px 0;
+}
+
+.sermon-image-control .hide {
+ visibility: hidden;
+}
+
+.sermon-image-control .show {
+ visibility: visible;
+}
diff --git a/includes/taxonomy-images/css/controls.png b/includes/vendor/taxonomy-images/css/controls.png
similarity index 100%
rename from includes/taxonomy-images/css/controls.png
rename to includes/vendor/taxonomy-images/css/controls.png
diff --git a/includes/taxonomy-images/default.png b/includes/vendor/taxonomy-images/default.png
similarity index 100%
rename from includes/taxonomy-images/default.png
rename to includes/vendor/taxonomy-images/default.png
diff --git a/includes/taxonomy-images/js/edit-tags.js b/includes/vendor/taxonomy-images/js/edit-tags.js
similarity index 100%
rename from includes/taxonomy-images/js/edit-tags.js
rename to includes/vendor/taxonomy-images/js/edit-tags.js
diff --git a/includes/taxonomy-images/js/media-modal.js b/includes/vendor/taxonomy-images/js/media-modal.js
similarity index 100%
rename from includes/taxonomy-images/js/media-modal.js
rename to includes/vendor/taxonomy-images/js/media-modal.js
diff --git a/includes/taxonomy-images/js/media-upload-popup.js b/includes/vendor/taxonomy-images/js/media-upload-popup.js
similarity index 100%
rename from includes/taxonomy-images/js/media-upload-popup.js
rename to includes/vendor/taxonomy-images/js/media-upload-popup.js
diff --git a/includes/taxonomy-images/languages/taxonomy-images.pot b/includes/vendor/taxonomy-images/languages/taxonomy-images.pot
similarity index 95%
rename from includes/taxonomy-images/languages/taxonomy-images.pot
rename to includes/vendor/taxonomy-images/languages/taxonomy-images.pot
index 306b1b1..92146eb 100755
--- a/includes/taxonomy-images/languages/taxonomy-images.pot
+++ b/includes/vendor/taxonomy-images/languages/taxonomy-images.pot
@@ -1,221 +1,221 @@
-# Copyright (C) 2011 Taxonomy Images
-# This file is distributed under the same license as the Taxonomy Images package.
-msgid ""
-msgstr ""
-"Project-Id-Version: Taxonomy Images 0.7.2\n"
-"Report-Msgid-Bugs-To: http://wordpress.org/tag/taxonomy-images\n"
-"POT-Creation-Date: 2011-06-20 17:47:57+00:00\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME \n"
-"Language-Team: LANGUAGE \n"
-
-#: taxonomy-images.php:125
-msgid "Associate with %1$s"
-msgstr ""
-
-#: taxonomy-images.php:125 taxonomy-images.php:127
-msgid "this term"
-msgstr ""
-
-#: taxonomy-images.php:127
-msgid "Remove association with %1$s"
-msgstr ""
-
-#. translators: Notice displayed on the custom administration page.
-#: taxonomy-images.php:281
-msgid "Image support for taxonomies successfully updated"
-msgstr ""
-
-#. translators: Notice displayed on the custom administration page.
-#: taxonomy-images.php:284
-msgid "Image support has been disabled for all taxonomies."
-msgstr ""
-
-#: taxonomy-images.php:324 taxonomy-images.php:1170
-msgid "Settings"
-msgstr ""
-
-#: taxonomy-images.php:330
-msgid "Taxonomies"
-msgstr ""
-
-#. #-#-#-#-# plugin.pot (Taxonomy Images 0.7.2) #-#-#-#-#
-#. Plugin Name of the plugin/theme
-#: taxonomy-images.php:349 taxonomy-images.php:350
-msgid "Taxonomy Images"
-msgstr ""
-
-#. translators: Heading of the custom administration page.
-#: taxonomy-images.php:377
-msgid "Taxonomy Images Plugin Settings"
-msgstr ""
-
-#. translators: Button on the custom administration page.
-#: taxonomy-images.php:385
-msgid "Save Changes"
-msgstr ""
-
-#. translators: An ajax request has failed for an unknown reason.
-#: taxonomy-images.php:432
-msgid "Unknown error encountered"
-msgstr ""
-
-#: taxonomy-images.php:507 taxonomy-images.php:589
-msgid "tt_id not sent"
-msgstr ""
-
-#: taxonomy-images.php:515 taxonomy-images.php:597
-msgid "tt_id is empty"
-msgstr ""
-
-#: taxonomy-images.php:522 taxonomy-images.php:604
-msgid "You do not have the correct capability to manage this term"
-msgstr ""
-
-#: taxonomy-images.php:529
-msgid "No nonce included."
-msgstr ""
-
-#: taxonomy-images.php:536 taxonomy-images.php:618
-msgid "Nonce did not match"
-msgstr ""
-
-#: taxonomy-images.php:543
-msgid "Image id not sent"
-msgstr ""
-
-#: taxonomy-images.php:551
-msgid "Image id is not a positive integer"
-msgstr ""
-
-#: taxonomy-images.php:560
-msgid "Image successfully associated"
-msgstr ""
-
-#: taxonomy-images.php:567
-msgid "Association could not be created"
-msgstr ""
-
-#: taxonomy-images.php:611
-msgid "No nonce included"
-msgstr ""
-
-#: taxonomy-images.php:626
-msgid "Nothing to remove"
-msgstr ""
-
-#: taxonomy-images.php:635
-msgid "Association successfully removed"
-msgstr ""
-
-#: taxonomy-images.php:641
-msgid "Association could not be removed"
-msgstr ""
-
-#: taxonomy-images.php:711 taxonomy-images.php:760
-msgid "Image"
-msgstr ""
-
-#: taxonomy-images.php:754 taxonomy-images.php:790
-msgid "term"
-msgstr ""
-
-#: taxonomy-images.php:764
-msgid "Associate an image from your media library to this %1$s."
-msgstr ""
-
-#: taxonomy-images.php:808
-msgid "Associate an image with the %1$s named “%2$s”."
-msgstr ""
-
-#: taxonomy-images.php:809
-msgid "Upload a new image for this %s."
-msgstr ""
-
-#: taxonomy-images.php:809
-msgid "Upload."
-msgstr ""
-
-#: taxonomy-images.php:810
-msgid "Remove image from this %s."
-msgstr ""
-
-#: taxonomy-images.php:810
-msgid "Delete"
-msgstr ""
-
-#: taxonomy-images.php:839
-msgid "“"
-msgstr ""
-
-#: taxonomy-images.php:840
-msgid "”"
-msgstr ""
-
-#: taxonomy-images.php:841
-msgid "Associating …"
-msgstr ""
-
-#: taxonomy-images.php:842
-msgid "Successfully Associated"
-msgstr ""
-
-#: taxonomy-images.php:843
-msgid "Removing …"
-msgstr ""
-
-#: taxonomy-images.php:844
-msgid "Successfully Removed"
-msgstr ""
-
-#: taxonomy-images.php:1098
-msgid ""
-"The %1$s argument for %2$s is set to %3$s which is not a registered "
-"taxonomy. Please check the spelling and update the argument."
-msgstr ""
-
-#: taxonomy-images.php:1099
-msgid "taxonomy"
-msgstr ""
-
-#: taxonomy-images.php:1109
-msgid "No taxonomies have image support. %1$s"
-msgstr ""
-
-#: taxonomy-images.php:1114
-msgid "The %1$s taxonomy does not have image support. %2$s"
-msgstr ""
-
-#: taxonomy-images.php:1139
-msgid "The %1$s has been called directly. Please use the %2$s filter instead."
-msgstr ""
-
-#: taxonomy-images.php:1175
-msgid "Donate"
-msgstr ""
-
-#: taxonomy-images.php:1193
-msgid "Manage Settings"
-msgstr ""
-
-#: public-filters.php:376
-msgid ""
-"%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: category.php, tag.php or "
-"taxonomy.php. Learn more about %3$s."
-msgstr ""
-
-#: public-filters.php:377
-msgid "term_taxonomy_id"
-msgstr ""
-
-#. Description of the plugin/theme
-msgid ""
-"Associate images from your media library to categories, tags and custom "
-"taxonomies."
-msgstr ""
+# Copyright (C) 2011 Taxonomy Images
+# This file is distributed under the same license as the Taxonomy Images package.
+msgid ""
+msgstr ""
+"Project-Id-Version: Taxonomy Images 0.7.2\n"
+"Report-Msgid-Bugs-To: http://wordpress.org/tag/taxonomy-images\n"
+"POT-Creation-Date: 2011-06-20 17:47:57+00:00\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+
+#: taxonomy-images.php:125
+msgid "Associate with %1$s"
+msgstr ""
+
+#: taxonomy-images.php:125 taxonomy-images.php:127
+msgid "this term"
+msgstr ""
+
+#: taxonomy-images.php:127
+msgid "Remove association with %1$s"
+msgstr ""
+
+#. translators: Notice displayed on the custom administration page.
+#: taxonomy-images.php:281
+msgid "Image support for taxonomies successfully updated"
+msgstr ""
+
+#. translators: Notice displayed on the custom administration page.
+#: taxonomy-images.php:284
+msgid "Image support has been disabled for all taxonomies."
+msgstr ""
+
+#: taxonomy-images.php:324 taxonomy-images.php:1170
+msgid "Settings"
+msgstr ""
+
+#: taxonomy-images.php:330
+msgid "Taxonomies"
+msgstr ""
+
+#. #-#-#-#-# plugin.pot (Taxonomy Images 0.7.2) #-#-#-#-#
+#. Plugin Name of the plugin/theme
+#: taxonomy-images.php:349 taxonomy-images.php:350
+msgid "Taxonomy Images"
+msgstr ""
+
+#. translators: Heading of the custom administration page.
+#: taxonomy-images.php:377
+msgid "Taxonomy Images Plugin Settings"
+msgstr ""
+
+#. translators: Button on the custom administration page.
+#: taxonomy-images.php:385
+msgid "Save Changes"
+msgstr ""
+
+#. translators: An ajax request has failed for an unknown reason.
+#: taxonomy-images.php:432
+msgid "Unknown error encountered"
+msgstr ""
+
+#: taxonomy-images.php:507 taxonomy-images.php:589
+msgid "tt_id not sent"
+msgstr ""
+
+#: taxonomy-images.php:515 taxonomy-images.php:597
+msgid "tt_id is empty"
+msgstr ""
+
+#: taxonomy-images.php:522 taxonomy-images.php:604
+msgid "You do not have the correct capability to manage this term"
+msgstr ""
+
+#: taxonomy-images.php:529
+msgid "No nonce included."
+msgstr ""
+
+#: taxonomy-images.php:536 taxonomy-images.php:618
+msgid "Nonce did not match"
+msgstr ""
+
+#: taxonomy-images.php:543
+msgid "Image id not sent"
+msgstr ""
+
+#: taxonomy-images.php:551
+msgid "Image id is not a positive integer"
+msgstr ""
+
+#: taxonomy-images.php:560
+msgid "Image successfully associated"
+msgstr ""
+
+#: taxonomy-images.php:567
+msgid "Association could not be created"
+msgstr ""
+
+#: taxonomy-images.php:611
+msgid "No nonce included"
+msgstr ""
+
+#: taxonomy-images.php:626
+msgid "Nothing to remove"
+msgstr ""
+
+#: taxonomy-images.php:635
+msgid "Association successfully removed"
+msgstr ""
+
+#: taxonomy-images.php:641
+msgid "Association could not be removed"
+msgstr ""
+
+#: taxonomy-images.php:711 taxonomy-images.php:760
+msgid "Image"
+msgstr ""
+
+#: taxonomy-images.php:754 taxonomy-images.php:790
+msgid "term"
+msgstr ""
+
+#: taxonomy-images.php:764
+msgid "Associate an image from your media library to this %1$s."
+msgstr ""
+
+#: taxonomy-images.php:808
+msgid "Associate an image with the %1$s named “%2$s”."
+msgstr ""
+
+#: taxonomy-images.php:809
+msgid "Upload a new image for this %s."
+msgstr ""
+
+#: taxonomy-images.php:809
+msgid "Upload."
+msgstr ""
+
+#: taxonomy-images.php:810
+msgid "Remove image from this %s."
+msgstr ""
+
+#: taxonomy-images.php:810
+msgid "Delete"
+msgstr ""
+
+#: taxonomy-images.php:839
+msgid "“"
+msgstr ""
+
+#: taxonomy-images.php:840
+msgid "”"
+msgstr ""
+
+#: taxonomy-images.php:841
+msgid "Associating …"
+msgstr ""
+
+#: taxonomy-images.php:842
+msgid "Successfully Associated"
+msgstr ""
+
+#: taxonomy-images.php:843
+msgid "Removing …"
+msgstr ""
+
+#: taxonomy-images.php:844
+msgid "Successfully Removed"
+msgstr ""
+
+#: taxonomy-images.php:1098
+msgid ""
+"The %1$s argument for %2$s is set to %3$s which is not a registered "
+"taxonomy. Please check the spelling and update the argument."
+msgstr ""
+
+#: taxonomy-images.php:1099
+msgid "taxonomy"
+msgstr ""
+
+#: taxonomy-images.php:1109
+msgid "No taxonomies have image support. %1$s"
+msgstr ""
+
+#: taxonomy-images.php:1114
+msgid "The %1$s taxonomy does not have image support. %2$s"
+msgstr ""
+
+#: taxonomy-images.php:1139
+msgid "The %1$s has been called directly. Please use the %2$s filter instead."
+msgstr ""
+
+#: taxonomy-images.php:1175
+msgid "Donate"
+msgstr ""
+
+#: taxonomy-images.php:1193
+msgid "Manage Settings"
+msgstr ""
+
+#: public-filters.php:376
+msgid ""
+"%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: category.php, tag.php or "
+"taxonomy.php. Learn more about %3$s."
+msgstr ""
+
+#: public-filters.php:377
+msgid "term_taxonomy_id"
+msgstr ""
+
+#. Description of the plugin/theme
+msgid ""
+"Associate images from your media library to categories, tags and custom "
+"taxonomies."
+msgstr ""
diff --git a/includes/taxonomy-images/public-filters.php b/includes/vendor/taxonomy-images/public-filters.php
similarity index 96%
rename from includes/taxonomy-images/public-filters.php
rename to includes/vendor/taxonomy-images/public-filters.php
index 46d414a..2227934 100755
--- a/includes/taxonomy-images/public-filters.php
+++ b/includes/vendor/taxonomy-images/public-filters.php
@@ -1,570 +1,570 @@
-
- * @copyright Copyright (c) 2011, Michael Fields
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
- * @since 0.7
- */
-
-
-add_filter( 'sermon-images-get-terms', 'sermon_images_plugin_get_terms', 10, 2 );
-add_filter( 'sermon-images-get-the-terms', 'sermon_images_plugin_get_the_terms', 10, 2 );
-add_filter( 'sermon-images-list-the-terms', 'sermon_images_plugin_list_the_terms', 10, 2 );
-
-add_filter( 'sermon-images-queried-term-image', 'sermon_images_plugin_get_queried_term_image', 10, 2 );
-add_filter( 'sermon-images-queried-term-image-data', 'sermon_images_plugin_get_queried_term_image_data', 10, 2 );
-add_filter( 'sermon-images-queried-term-image-id', 'sermon_images_plugin_get_queried_term_image_id' );
-add_filter( 'sermon-images-queried-term-image-object', 'sermon_images_plugin_get_queried_term_image_object' );
-add_filter( 'sermon-images-queried-term-image-url', 'sermon_images_plugin_get_queried_term_image_url', 10, 2 );
-
-
-/**
- * Get Terms.
- *
- * This function adds a custom property (image_id) to each
- * object returned by WordPress core function get_terms().
- * This property will be set for all term objects. In cases
- * where a term has an associated image, "image_id" will
- * contain the value of the image object's ID property. If
- * no image has been associated, this property will contain
- * integer with the value of zero.
- *
- * Recognized Arguments:
- *
- * cache_images (bool) A non-empty value will trigger
- * this function to query for and cache all associated
- * images. An empty value disables caching. Defaults to
- * boolean true.
- *
- * having_images (bool) A non-empty value will trigger
- * this function to only return terms that have associated
- * images. If an empty value is passed all terms of the
- * taxonomy will be returned.
- *
- * taxonomy (string) Name of a registered taxonomy to
- * return terms from. Defaults to "category".
- *
- * term_args (array) Arguments to pass as the second
- * parameter of get_terms(). Defaults to an empty array.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- * @param array Named arguments. Please see above for explantion.
- *
- * @return array List of term objects.
- *
- * @access private Use the 'sermon-images-get-terms' filter.
- * @since 0.7
- */
-function sermon_images_plugin_get_terms( $default, $args = array() ) {
- $filter = 'sermon-images-get-terms';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $args = wp_parse_args( $args, array(
- 'cache_images' => true,
- 'having_images' => true,
- 'taxonomy' => 'wpfc_sermon_series',
- 'term_args' => array(),
- ) );
-
- $args['taxonomy'] = explode( ',', $args['taxonomy'] );
- $args['taxonomy'] = array_map( 'trim', $args['taxonomy'] );
-
- foreach ( $args['taxonomy'] as $taxonomy ) {
- if ( ! sermon_image_plugin_check_taxonomy( $taxonomy, $filter ) ) {
- return array();
- }
- }
-
- $assoc = sermon_image_plugin_get_associations();
- if ( empty( $assoc ) ) {
- return array();
- }
-
- $terms = get_terms( $args['taxonomy'], $args['term_args'] );
- if ( is_wp_error( $terms ) ) {
- return array();
- }
-
- $image_ids = array();
- $terms_with_images = array();
- foreach ( (array) $terms as $key => $term ) {
- $terms[ $key ]->image_id = 0;
- if ( array_key_exists( $term->term_taxonomy_id, $assoc ) ) {
- $terms[ $key ]->image_id = $assoc[ $term->term_taxonomy_id ];
- $image_ids[] = $assoc[ $term->term_taxonomy_id ];
- if ( ! empty( $args['having_images'] ) ) {
- $terms_with_images[] = $terms[ $key ];
- }
- }
- }
- $image_ids = array_unique( $image_ids );
-
- if ( ! empty( $args['cache_images'] ) ) {
- $images = array();
- if ( ! empty( $image_ids ) ) {
- $images = get_children( array( 'include' => implode( ',', $image_ids ) ) );
- }
- }
-
- if ( ! empty( $terms_with_images ) ) {
- return $terms_with_images;
- }
-
- return $terms;
-}
-
-
-/**
- * Get the Terms.
- *
- * This function adds a custom property (image_id) to each
- * object returned by WordPress core function get_the_terms().
- * This property will be set for all term objects. In cases
- * where a term has an associated image, "image_id" will
- * contain the value of the image object's ID property. If
- * no image has been associated, this property will contain
- * integer with the value of zero.
- *
- * Recognized Arguments:
- *
- * having_images (bool) A non-empty value will trigger
- * this function to only return terms that have associated
- * images. If an empty value is passed all terms of the
- * taxonomy will be returned. Optional.
- *
- * post_id (int) The post to retrieve terms from. Defaults
- * to the ID property of the global $post object. Optional.
- *
- * taxonomy (string) Name of a registered taxonomy to
- * return terms from. Defaults to "category". Optional.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- * @param array Named arguments. Please see above for explantion.
- *
- * @return array List of term objects. Empty array if none were found.
- *
- * @access private Use the 'sermon-images-get-the-terms' filter.
- * @since 0.7
- */
-function sermon_images_plugin_get_the_terms( $default, $args ) {
- $filter = 'sermon-images-get-the-terms';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $args = wp_parse_args( $args, array(
- 'having_images' => true,
- 'post_id' => 0,
- 'taxonomy' => 'wpfc_sermon_series',
- ) );
-
- if ( ! sermon_image_plugin_check_taxonomy( $args['taxonomy'], $filter ) ) {
- return array();
- }
-
- $assoc = sermon_image_plugin_get_associations();
-
- if ( empty( $args['post_id'] ) ) {
- $args['post_id'] = get_the_ID();
- }
-
- $terms = get_the_terms( $args['post_id'], $args['taxonomy'] );
-
- if ( is_wp_error( $terms ) ) {
- return array();
- }
-
- if ( empty( $terms ) ) {
- return array();
- }
-
- $terms_with_images = array();
- foreach ( (array) $terms as $key => $term ) {
- $terms[ $key ]->image_id = 0;
- if ( array_key_exists( $term->term_taxonomy_id, $assoc ) ) {
- $terms[ $key ]->image_id = $assoc[ $term->term_taxonomy_id ];
- if ( ! empty( $args['having_images'] ) ) {
- $terms_with_images[] = $terms[ $key ];
- }
- }
- }
- if ( ! empty( $terms_with_images ) ) {
- return $terms_with_images;
- }
-
- return $terms;
-}
-
-
-/**
- * List the Terms.
- *
- * Lists all terms associated with a given post that
- * have associated images. Terms without images will
- * not be included.
- *
- * Recognized Arguments:
- *
- * after (string) Text to append to the output. Optional.
- * Defaults to an empty string.
- *
- * before (string) Text to preppend to the output. Optional.
- * Defaults to an empty string.
- *
- * 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 un modified image that was uploaded.
- * Optional. Defaults to "thumbnail".
- *
- * post_id (int) The post to retrieve terms from. Defaults
- * to the ID property of the global $post object. Optional.
- *
- * taxonomy (string) Name of a registered taxonomy to
- * return terms from. Defaults to "category". Optional.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- * @param array Named arguments. Please see above for explantion.
- *
- * @return string HTML markup.
- *
- * @access private Use the 'sermon-images-list-the-terms' filter.
- * @since 0.7
- */
-function sermon_images_plugin_list_the_terms( $default, $args ) {
- $filter = 'sermon-images-list-the-terms';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $args = wp_parse_args( $args, array(
- 'after' => '',
- 'after_image' => '',
- 'before' => '',
- 'before_image' => '',
- 'image_size' => 'thumbnail',
- 'post_id' => 0,
- 'taxonomy' => 'wpfc_sermon_series',
- ) );
-
- $args['having_images'] = true;
-
- if ( ! sermon_image_plugin_check_taxonomy( $args['taxonomy'], $filter ) ) {
- return '';
- }
-
- $terms = apply_filters( 'sermon-images-get-the-terms', '', $args );
-
- if ( empty( $terms ) ) {
- return '';
- }
-
- $output = '';
- foreach ( $terms as $term ) {
- if ( ! isset( $term->image_id ) ) {
- continue;
- }
- $image = wp_get_attachment_image( $term->image_id, $args['image_size'] );
- if ( ! empty( $image ) ) {
- $output .= $args['before_image'] . '' . $image . ' ' . $args['after_image'];
- }
- }
-
- if ( ! empty( $output ) ) {
- return $args['before'] . $output . $args['after'];
- }
-
- return '';
-}
-
-
-/**
- * Queried Term Image.
- *
- * Prints html marking up the images associated with
- * the current queried term.
- *
- * Recognized Arguments:
- *
- * after (string) - Text to append to the image's HTML.
- *
- * 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 function will return an empty string.
- *
- * Designed to be used in archive templates including
- * (but not limited to) archive.php,
- * taxonomy.php as well as derivatives of these templates.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- * @param array Named array of arguments.
- *
- * @return string HTML markup for the associated image.
- *
- * @access private Use the 'sermon-images-queried-term-image' filter.
- * @since 0.7
- */
-function sermon_images_plugin_get_queried_term_image( $default, $args = array() ) {
- $filter = 'sermon-images-queried-term-image';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $args = wp_parse_args( $args, array(
- 'after' => '',
- 'attr' => array(),
- 'before' => '',
- 'image_size' => 'thumbnail',
- ) );
-
- $ID = apply_filters( 'sermon-images-queried-term-image-id', 0 );
-
- if ( empty( $ID ) ) {
- return '';
- }
-
- $html = wp_get_attachment_image( $ID, $args['image_size'], false, $args['attr'] );
-
- if ( empty( $html ) ) {
- return '';
- }
-
- return $args['before'] . $html . $args['after'];
-}
-
-
-/**
- * Queried Term Image ID.
- *
- * Designed to be used in archive templates including
- * (but not limited to) archive.php, category.php, tag.php,
- * taxonomy.php as well as derivatives of these templates.
- *
- * Returns an integer representing the image attachment's ID.
- * In the event that an image has been associated zero will
- * be returned.
- *
- * This function should never be called directly in any file
- * however it may be access in any template file via the
- * 'sermon-images-queried-term-image-id' filter.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- *
- * @return int Image attachment's ID.
- *
- * @access private Use the 'sermon-images-queried-term-image-id' filter.
- * @since 0.7
- */
-function sermon_images_plugin_get_queried_term_image_id( $default ) {
- $filter = 'sermon-images-queried-term-image-id';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $obj = get_queried_object();
-
- /* 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 ) . '
',
- 'category.php
',
- 'tag.php
',
- 'taxonomy.php
',
- '' . esc_html__( 'template hierarchy', 'sermon-manager-for-wordpress' ) . ' '
- ) );
-
- return 0;
- }
-
- if ( ! sermon_image_plugin_check_taxonomy( $obj->taxonomy, $filter ) ) {
- return 0;
- }
-
- $associations = sermon_image_plugin_get_associations();
- $tt_id = absint( $obj->term_taxonomy_id );
-
- $ID = 0;
- if ( array_key_exists( $tt_id, $associations ) ) {
- $ID = absint( $associations[ $tt_id ] );
- }
-
- return $ID;
-}
-
-
-/**
- * Queried Term Image Object.
- *
- * Returns all data stored in the WordPress posts table for
- * the image associated with the term in object form. In the
- * event that no image is found an empty object will be returned.
- *
- * Designed to be used in archive templates including
- * (but not limited to) archive.php, category.php, tag.php,
- * taxonomy.php as well as derivatives of these templates.
- *
- * This function should never be called directly in any file
- * however it may be access in any template file via the
- * 'sermon-images-queried-term-image' filter.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- *
- * @return stdClass WordPress Post object.
- *
- * @access private Use the 'sermon-images-queried-term-image-object' filter.
- * @since 0.7
- */
-function sermon_images_plugin_get_queried_term_image_object( $default ) {
- $filter = 'sermon-images-queried-term-image-object';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $ID = apply_filters( 'sermon-images-queried-term-image-id', 0 );
-
- $image = new stdClass;
- if ( ! empty( $ID ) ) {
- $image = get_post( $ID );
- }
-
- return $image;
-}
-
-/**
- * Queried Term Image URL.
- *
- * Returns a url to the image associated with the current queried
- * term. In the event that no image is found an empty string will
- * be returned.
- *
- * Designed to be used in archive templates including
- * (but not limited to) archive.php, category.php, tag.php,
- * taxonomy.php as well as derivatives of these templates.
- *
- * Recognized Arguments
- *
- * 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 function will return an empty string.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- * @param array Named Arguments.
- *
- * @return string Image URL.
- *
- * @access private Use the 'sermon-images-queried-term-image-url' filter.
- * @since 0.7
- */
-function sermon_images_plugin_get_queried_term_image_url( $default, $args = array() ) {
- $filter = 'sermon-images-queried-term-image-url';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $args = wp_parse_args( $args, array(
- 'image_size' => 'thumbnail',
- ) );
-
- $data = apply_filters( 'sermon-images-queried-term-image-data', array(), $args );
-
- $url = '';
- if ( isset( $data['url'] ) ) {
- $url = $data['url'];
- }
-
- return $url;
-}
-
-
-/**
- * Queried Term Image Data.
- *
- * Returns a url to the image associated with the current queried
- * term. In the event that no image is found an empty string will
- * be returned.
- *
- * Designed to be used in archive templates including
- * (but not limited to) archive.php, category.php, tag.php,
- * taxonomy.php as well as derivatives of these templates.
- *
- * Recognized Arguments
- *
- * 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 function will return an empty array.
- *
- * @param mixed Default value for apply_filters() to return. Unused.
- * @param array Named Arguments.
- *
- * @return array Image data: url, width and height.
- *
- * @access private Use the 'sermon-images-queried-term-image-data' filter.
- * @since 0.7
- * @alter 0.7.2
- */
-function sermon_images_plugin_get_queried_term_image_data( $default, $args = array() ) {
- $filter = 'sermon-images-queried-term-image-data';
- if ( $filter !== current_filter() ) {
- sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
- }
-
- $args = wp_parse_args( $args, array(
- 'image_size' => 'thumbnail',
- ) );
-
- $ID = apply_filters( 'sermon-images-queried-term-image-id', 0 );
-
- if ( empty( $ID ) ) {
- return array();
- }
-
- $data = array();
-
- if ( in_array( $args['image_size'], array( 'full', 'fullsize' ) ) ) {
- $src = wp_get_attachment_image_src( $ID, 'full' );
-
- if ( isset( $src[0] ) ) {
- $data['url'] = $src[0];
- }
- if ( isset( $src[1] ) ) {
- $data['width'] = $src[1];
- }
- if ( isset( $src[2] ) ) {
- $data['height'] = $src[2];
- }
- } else {
- $data = image_get_intermediate_size( $ID, $args['image_size'] );
- }
-
- if ( ! empty( $data ) ) {
- return $data;
- }
-
- return array();
-}
+
+ * @copyright Copyright (c) 2011, Michael Fields
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
+ * @since 0.7
+ */
+
+
+add_filter( 'sermon-images-get-terms', 'sermon_images_plugin_get_terms', 10, 2 );
+add_filter( 'sermon-images-get-the-terms', 'sermon_images_plugin_get_the_terms', 10, 2 );
+add_filter( 'sermon-images-list-the-terms', 'sermon_images_plugin_list_the_terms', 10, 2 );
+
+add_filter( 'sermon-images-queried-term-image', 'sermon_images_plugin_get_queried_term_image', 10, 2 );
+add_filter( 'sermon-images-queried-term-image-data', 'sermon_images_plugin_get_queried_term_image_data', 10, 2 );
+add_filter( 'sermon-images-queried-term-image-id', 'sermon_images_plugin_get_queried_term_image_id' );
+add_filter( 'sermon-images-queried-term-image-object', 'sermon_images_plugin_get_queried_term_image_object' );
+add_filter( 'sermon-images-queried-term-image-url', 'sermon_images_plugin_get_queried_term_image_url', 10, 2 );
+
+
+/**
+ * Get Terms.
+ *
+ * This function adds a custom property (image_id) to each
+ * object returned by WordPress core function get_terms().
+ * This property will be set for all term objects. In cases
+ * where a term has an associated image, "image_id" will
+ * contain the value of the image object's ID property. If
+ * no image has been associated, this property will contain
+ * integer with the value of zero.
+ *
+ * Recognized Arguments:
+ *
+ * cache_images (bool) A non-empty value will trigger
+ * this function to query for and cache all associated
+ * images. An empty value disables caching. Defaults to
+ * boolean true.
+ *
+ * having_images (bool) A non-empty value will trigger
+ * this function to only return terms that have associated
+ * images. If an empty value is passed all terms of the
+ * taxonomy will be returned.
+ *
+ * taxonomy (string) Name of a registered taxonomy to
+ * return terms from. Defaults to "category".
+ *
+ * term_args (array) Arguments to pass as the second
+ * parameter of get_terms(). Defaults to an empty array.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ * @param array Named arguments. Please see above for explantion.
+ *
+ * @return array List of term objects.
+ *
+ * @access private Use the 'sermon-images-get-terms' filter.
+ * @since 0.7
+ */
+function sermon_images_plugin_get_terms( $default, $args = array() ) {
+ $filter = 'sermon-images-get-terms';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $args = wp_parse_args( $args, array(
+ 'cache_images' => true,
+ 'having_images' => true,
+ 'taxonomy' => 'wpfc_sermon_series',
+ 'term_args' => array(),
+ ) );
+
+ $args['taxonomy'] = explode( ',', $args['taxonomy'] );
+ $args['taxonomy'] = array_map( 'trim', $args['taxonomy'] );
+
+ foreach ( $args['taxonomy'] as $taxonomy ) {
+ if ( ! sermon_image_plugin_check_taxonomy( $taxonomy, $filter ) ) {
+ return array();
+ }
+ }
+
+ $assoc = sermon_image_plugin_get_associations();
+ if ( empty( $assoc ) ) {
+ return array();
+ }
+
+ $terms = get_terms( $args['taxonomy'], $args['term_args'] );
+ if ( is_wp_error( $terms ) ) {
+ return array();
+ }
+
+ $image_ids = array();
+ $terms_with_images = array();
+ foreach ( (array) $terms as $key => $term ) {
+ $terms[ $key ]->image_id = 0;
+ if ( array_key_exists( $term->term_taxonomy_id, $assoc ) ) {
+ $terms[ $key ]->image_id = $assoc[ $term->term_taxonomy_id ];
+ $image_ids[] = $assoc[ $term->term_taxonomy_id ];
+ if ( ! empty( $args['having_images'] ) ) {
+ $terms_with_images[] = $terms[ $key ];
+ }
+ }
+ }
+ $image_ids = array_unique( $image_ids );
+
+ if ( ! empty( $args['cache_images'] ) ) {
+ $images = array();
+ if ( ! empty( $image_ids ) ) {
+ $images = get_children( array( 'include' => implode( ',', $image_ids ) ) );
+ }
+ }
+
+ if ( ! empty( $terms_with_images ) ) {
+ return $terms_with_images;
+ }
+
+ return $terms;
+}
+
+
+/**
+ * Get the Terms.
+ *
+ * This function adds a custom property (image_id) to each
+ * object returned by WordPress core function get_the_terms().
+ * This property will be set for all term objects. In cases
+ * where a term has an associated image, "image_id" will
+ * contain the value of the image object's ID property. If
+ * no image has been associated, this property will contain
+ * integer with the value of zero.
+ *
+ * Recognized Arguments:
+ *
+ * having_images (bool) A non-empty value will trigger
+ * this function to only return terms that have associated
+ * images. If an empty value is passed all terms of the
+ * taxonomy will be returned. Optional.
+ *
+ * post_id (int) The post to retrieve terms from. Defaults
+ * to the ID property of the global $post object. Optional.
+ *
+ * taxonomy (string) Name of a registered taxonomy to
+ * return terms from. Defaults to "category". Optional.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ * @param array Named arguments. Please see above for explantion.
+ *
+ * @return array List of term objects. Empty array if none were found.
+ *
+ * @access private Use the 'sermon-images-get-the-terms' filter.
+ * @since 0.7
+ */
+function sermon_images_plugin_get_the_terms( $default, $args ) {
+ $filter = 'sermon-images-get-the-terms';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $args = wp_parse_args( $args, array(
+ 'having_images' => true,
+ 'post_id' => 0,
+ 'taxonomy' => 'wpfc_sermon_series',
+ ) );
+
+ if ( ! sermon_image_plugin_check_taxonomy( $args['taxonomy'], $filter ) ) {
+ return array();
+ }
+
+ $assoc = sermon_image_plugin_get_associations();
+
+ if ( empty( $args['post_id'] ) ) {
+ $args['post_id'] = get_the_ID();
+ }
+
+ $terms = get_the_terms( $args['post_id'], $args['taxonomy'] );
+
+ if ( is_wp_error( $terms ) ) {
+ return array();
+ }
+
+ if ( empty( $terms ) ) {
+ return array();
+ }
+
+ $terms_with_images = array();
+ foreach ( (array) $terms as $key => $term ) {
+ $terms[ $key ]->image_id = 0;
+ if ( array_key_exists( $term->term_taxonomy_id, $assoc ) ) {
+ $terms[ $key ]->image_id = $assoc[ $term->term_taxonomy_id ];
+ if ( ! empty( $args['having_images'] ) ) {
+ $terms_with_images[] = $terms[ $key ];
+ }
+ }
+ }
+ if ( ! empty( $terms_with_images ) ) {
+ return $terms_with_images;
+ }
+
+ return $terms;
+}
+
+
+/**
+ * List the Terms.
+ *
+ * Lists all terms associated with a given post that
+ * have associated images. Terms without images will
+ * not be included.
+ *
+ * Recognized Arguments:
+ *
+ * after (string) Text to append to the output. Optional.
+ * Defaults to an empty string.
+ *
+ * before (string) Text to preppend to the output. Optional.
+ * Defaults to an empty string.
+ *
+ * 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 un modified image that was uploaded.
+ * Optional. Defaults to "thumbnail".
+ *
+ * post_id (int) The post to retrieve terms from. Defaults
+ * to the ID property of the global $post object. Optional.
+ *
+ * taxonomy (string) Name of a registered taxonomy to
+ * return terms from. Defaults to "category". Optional.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ * @param array Named arguments. Please see above for explantion.
+ *
+ * @return string HTML markup.
+ *
+ * @access private Use the 'sermon-images-list-the-terms' filter.
+ * @since 0.7
+ */
+function sermon_images_plugin_list_the_terms( $default, $args ) {
+ $filter = 'sermon-images-list-the-terms';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $args = wp_parse_args( $args, array(
+ 'after' => ' ',
+ 'after_image' => '',
+ 'before' => '',
+ 'before_image' => '',
+ 'image_size' => 'thumbnail',
+ 'post_id' => 0,
+ 'taxonomy' => 'wpfc_sermon_series',
+ ) );
+
+ $args['having_images'] = true;
+
+ if ( ! sermon_image_plugin_check_taxonomy( $args['taxonomy'], $filter ) ) {
+ return '';
+ }
+
+ $terms = apply_filters( 'sermon-images-get-the-terms', '', $args );
+
+ if ( empty( $terms ) ) {
+ return '';
+ }
+
+ $output = '';
+ foreach ( $terms as $term ) {
+ if ( ! isset( $term->image_id ) ) {
+ continue;
+ }
+ $image = wp_get_attachment_image( $term->image_id, $args['image_size'] );
+ if ( ! empty( $image ) ) {
+ $output .= $args['before_image'] . '' . $image . ' ' . $args['after_image'];
+ }
+ }
+
+ if ( ! empty( $output ) ) {
+ return $args['before'] . $output . $args['after'];
+ }
+
+ return '';
+}
+
+
+/**
+ * Queried Term Image.
+ *
+ * Prints html marking up the images associated with
+ * the current queried term.
+ *
+ * Recognized Arguments:
+ *
+ * after (string) - Text to append to the image's HTML.
+ *
+ * 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 function will return an empty string.
+ *
+ * Designed to be used in archive templates including
+ * (but not limited to) archive.php,
+ * taxonomy.php as well as derivatives of these templates.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ * @param array Named array of arguments.
+ *
+ * @return string HTML markup for the associated image.
+ *
+ * @access private Use the 'sermon-images-queried-term-image' filter.
+ * @since 0.7
+ */
+function sermon_images_plugin_get_queried_term_image( $default, $args = array() ) {
+ $filter = 'sermon-images-queried-term-image';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $args = wp_parse_args( $args, array(
+ 'after' => '',
+ 'attr' => array(),
+ 'before' => '',
+ 'image_size' => 'thumbnail',
+ ) );
+
+ $ID = apply_filters( 'sermon-images-queried-term-image-id', 0 );
+
+ if ( empty( $ID ) ) {
+ return '';
+ }
+
+ $html = wp_get_attachment_image( $ID, $args['image_size'], false, $args['attr'] );
+
+ if ( empty( $html ) ) {
+ return '';
+ }
+
+ return $args['before'] . $html . $args['after'];
+}
+
+
+/**
+ * Queried Term Image ID.
+ *
+ * Designed to be used in archive templates including
+ * (but not limited to) archive.php, category.php, tag.php,
+ * taxonomy.php as well as derivatives of these templates.
+ *
+ * Returns an integer representing the image attachment's ID.
+ * In the event that an image has been associated zero will
+ * be returned.
+ *
+ * This function should never be called directly in any file
+ * however it may be access in any template file via the
+ * 'sermon-images-queried-term-image-id' filter.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ *
+ * @return int Image attachment's ID.
+ *
+ * @access private Use the 'sermon-images-queried-term-image-id' filter.
+ * @since 0.7
+ */
+function sermon_images_plugin_get_queried_term_image_id( $default ) {
+ $filter = 'sermon-images-queried-term-image-id';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $obj = get_queried_object();
+
+ /* 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 ) . '
',
+ 'category.php
',
+ 'tag.php
',
+ 'taxonomy.php
',
+ '' . esc_html__( 'template hierarchy', 'sermon-manager-for-wordpress' ) . ' '
+ ) );
+
+ return 0;
+ }
+
+ if ( ! sermon_image_plugin_check_taxonomy( $obj->taxonomy, $filter ) ) {
+ return 0;
+ }
+
+ $associations = sermon_image_plugin_get_associations();
+ $tt_id = absint( $obj->term_taxonomy_id );
+
+ $ID = 0;
+ if ( array_key_exists( $tt_id, $associations ) ) {
+ $ID = absint( $associations[ $tt_id ] );
+ }
+
+ return $ID;
+}
+
+
+/**
+ * Queried Term Image Object.
+ *
+ * Returns all data stored in the WordPress posts table for
+ * the image associated with the term in object form. In the
+ * event that no image is found an empty object will be returned.
+ *
+ * Designed to be used in archive templates including
+ * (but not limited to) archive.php, category.php, tag.php,
+ * taxonomy.php as well as derivatives of these templates.
+ *
+ * This function should never be called directly in any file
+ * however it may be access in any template file via the
+ * 'sermon-images-queried-term-image' filter.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ *
+ * @return stdClass WordPress Post object.
+ *
+ * @access private Use the 'sermon-images-queried-term-image-object' filter.
+ * @since 0.7
+ */
+function sermon_images_plugin_get_queried_term_image_object( $default ) {
+ $filter = 'sermon-images-queried-term-image-object';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $ID = apply_filters( 'sermon-images-queried-term-image-id', 0 );
+
+ $image = new stdClass;
+ if ( ! empty( $ID ) ) {
+ $image = get_post( $ID );
+ }
+
+ return $image;
+}
+
+/**
+ * Queried Term Image URL.
+ *
+ * Returns a url to the image associated with the current queried
+ * term. In the event that no image is found an empty string will
+ * be returned.
+ *
+ * Designed to be used in archive templates including
+ * (but not limited to) archive.php, category.php, tag.php,
+ * taxonomy.php as well as derivatives of these templates.
+ *
+ * Recognized Arguments
+ *
+ * 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 function will return an empty string.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ * @param array Named Arguments.
+ *
+ * @return string Image URL.
+ *
+ * @access private Use the 'sermon-images-queried-term-image-url' filter.
+ * @since 0.7
+ */
+function sermon_images_plugin_get_queried_term_image_url( $default, $args = array() ) {
+ $filter = 'sermon-images-queried-term-image-url';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $args = wp_parse_args( $args, array(
+ 'image_size' => 'thumbnail',
+ ) );
+
+ $data = apply_filters( 'sermon-images-queried-term-image-data', array(), $args );
+
+ $url = '';
+ if ( isset( $data['url'] ) ) {
+ $url = $data['url'];
+ }
+
+ return $url;
+}
+
+
+/**
+ * Queried Term Image Data.
+ *
+ * Returns a url to the image associated with the current queried
+ * term. In the event that no image is found an empty string will
+ * be returned.
+ *
+ * Designed to be used in archive templates including
+ * (but not limited to) archive.php, category.php, tag.php,
+ * taxonomy.php as well as derivatives of these templates.
+ *
+ * Recognized Arguments
+ *
+ * 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 function will return an empty array.
+ *
+ * @param mixed Default value for apply_filters() to return. Unused.
+ * @param array Named Arguments.
+ *
+ * @return array Image data: url, width and height.
+ *
+ * @access private Use the 'sermon-images-queried-term-image-data' filter.
+ * @since 0.7
+ * @alter 0.7.2
+ */
+function sermon_images_plugin_get_queried_term_image_data( $default, $args = array() ) {
+ $filter = 'sermon-images-queried-term-image-data';
+ if ( $filter !== current_filter() ) {
+ sermon_image_plugin_please_use_filter( __FUNCTION__, $filter );
+ }
+
+ $args = wp_parse_args( $args, array(
+ 'image_size' => 'thumbnail',
+ ) );
+
+ $ID = apply_filters( 'sermon-images-queried-term-image-id', 0 );
+
+ if ( empty( $ID ) ) {
+ return array();
+ }
+
+ $data = array();
+
+ if ( in_array( $args['image_size'], array( 'full', 'fullsize' ) ) ) {
+ $src = wp_get_attachment_image_src( $ID, 'full' );
+
+ if ( isset( $src[0] ) ) {
+ $data['url'] = $src[0];
+ }
+ if ( isset( $src[1] ) ) {
+ $data['width'] = $src[1];
+ }
+ if ( isset( $src[2] ) ) {
+ $data['height'] = $src[2];
+ }
+ } else {
+ $data = image_get_intermediate_size( $ID, $args['image_size'] );
+ }
+
+ if ( ! empty( $data ) ) {
+ return $data;
+ }
+
+ return array();
+}
diff --git a/includes/taxonomy-images/taxonomy-images.php b/includes/vendor/taxonomy-images/taxonomy-images.php
similarity index 99%
rename from includes/taxonomy-images/taxonomy-images.php
rename to includes/vendor/taxonomy-images/taxonomy-images.php
index fa62fee..53aac6f 100644
--- a/includes/taxonomy-images/taxonomy-images.php
+++ b/includes/vendor/taxonomy-images/taxonomy-images.php
@@ -939,7 +939,7 @@ function sermon_image_plugin_css_admin() {
wp_enqueue_style(
'sermon-image-plugin-edit-tags',
- sermon_image_plugin_url( 'css/admincss' ),
+ sermon_image_plugin_url( 'css/admin.css' ),
array(),
sermon_image_plugin_version(),
'screen'
diff --git a/includes/libraries/wp-async-request.php b/includes/vendor/wp-async-request.php
similarity index 100%
rename from includes/libraries/wp-async-request.php
rename to includes/vendor/wp-async-request.php
diff --git a/includes/libraries/wp-background-process.php b/includes/vendor/wp-background-process.php
similarity index 100%
rename from includes/libraries/wp-background-process.php
rename to includes/vendor/wp-background-process.php
diff --git a/includes/widgets.php b/includes/widgets.php
deleted file mode 100755
index 4bbff9c..0000000
--- a/includes/widgets.php
+++ /dev/null
@@ -1,156 +0,0 @@
- 'widget_recent_sermons',
- 'description' => __( 'The most recent sermons on your site', 'sermon-manager-for-wordpress' )
- );
- parent::__construct( 'recent-sermons', __( 'Recent Sermons', 'sermon-manager-for-wordpress' ), $widget_ops );
- $this->alt_option_name = 'widget_recent_entries';
-
- add_action( 'save_post', array( $this, 'flush_widget_cache' ) );
- add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) );
- add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) );
- }
-
- function widget( $args, $instance ) {
- // enqueue scripts and styles
- if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) {
- define( 'SM_ENQUEUE_SCRIPTS_STYLES', true );
- }
-
- $cache = wp_cache_get( 'widget_recent_sermons', 'widget' );
-
- if ( ! is_array( $cache ) ) {
- $cache = array();
- }
-
- if ( isset( $cache[ $args['widget_id'] ] ) ) {
- echo $cache[ $args['widget_id'] ];
-
- return;
- }
-
- ob_start();
- extract( $args );
-
- $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Sermons', 'sermon-manager-for-wordpress' ) : $instance['title'], $instance, $this->id_base );
- if ( ! $number = absint( $instance['number'] ) ) {
- $number = 10;
- }
-
- $r = new WP_Query( array(
- 'post_type' => 'wpfc_sermon',
- 'posts_per_page' => $number,
- 'no_found_rows' => true,
- 'post_status' => 'publish',
- 'ignore_sticky_posts' => true,
- 'meta_key' => 'sermon_date',
- 'meta_value_num' => time(),
- 'meta_compare' => '<=',
- 'orderby' => 'meta_value_num',
- 'order' => 'desc',
- ) );
- if ( $r->have_posts() ) :
- ?>
-
-
-
- have_posts() ) : $r->the_post(); ?>
-
-
-
-
-
-
-
- flush_widget_cache();
-
- $alloptions = wp_cache_get( 'alloptions', 'options' );
- if ( isset( $alloptions['widget_recent_entries'] ) ) {
- delete_option( 'widget_recent_entries' );
- }
-
- return $instance;
- }
-
- function flush_widget_cache() {
- wp_cache_delete( 'widget_recent_sermons', 'widget' );
- }
-
- function form( $instance ) {
- $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
- $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
- ?>
-
-
-
-
-
-
-
-
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
new file mode 100644
index 0000000..25f0302
--- /dev/null
+++ b/phpcs.xml.dist
@@ -0,0 +1,23 @@
+
+
+ Generally-applicable sniffs for WordPress plugins
+
+
+
+
+
+
+ .
+
+
+
+
+ */node_modules/*
+ */vendor/*
+
+
+
+
+
+
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..d9af975
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,15 @@
+
+
+
+
+ ./tests/
+
+
+
diff --git a/readme.txt b/readme.txt
index 7c51dab..96fa9a3 100755
--- a/readme.txt
+++ b/readme.txt
@@ -2,10 +2,10 @@
Contributors: wpforchurch, nikolam
Donate link: http://wpforchurch.com/
Tags: church, sermon, sermons, preaching, podcasting, manage, managing, podcasts, itunes
-Requires at least: 4.5
-Tested up to: 4.9
+Requires at least: 4.7.0
+Tested up to: 4.9
Requires PHP: 5.3
-Stable tag: 2.12.5
+Stable tag: 2.13.0
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -27,7 +27,7 @@ Sermon Manager is designed to help churches easily publish sermons online. Some
* Full-featured iTunes podcasting support for all sermons, plus each sermon series, preachers, sermon topics, or book of the Bible!
* Import sermons from other WordPress plugins
* PHP 5.3+ - you can use Sermon Manager even with older websites!
-* PHP 7.1 ready - Sermon Manager is 100% compatible with latest PHP version
+* PHP 7.2 ready - Sermon Manager is 100% compatible with latest PHP version
* Super flexible shortcode system
* Supports 3rd party plugins such as Yoast SEO, Jetpack, etc
* Quick and professional *free* and paid support
@@ -77,13 +77,13 @@ Installation is simple:
1. Just use the “Add New” button in Plugin section of your WordPress blog’s Control panel. To find the plugin there, search for `Sermon Manager`
2. Activate the plugin
3. Add a sermon through the Dashboard
-4. To display the sermons on the frontend of your site, just visit the `http://yourdomain.com/sermons` if you have permalinks enabled or `http://yourdomain.com/?post_type=wpfc_sermon` if not. Or you can use the shortcode `[sermons]` in any page.
+4. To display the sermons on the frontend of your site, just visit the `http://yourdomain.com/sermons` if you have pretty permalinks enabled or `http://yourdomain.com/?post_type=wpfc_sermon` if not. Or you can use the shortcode `[sermons]` in any page.
## Frequently Asked Questions ##
### How do I display sermons on the frontend? ###
-Visit the `http://yourdomain.com/sermons` if you have permalinks enabled or `http://yourdomain.com/?post_type=wpfc_sermon` if not. Or you can use the shortcode `[sermons]` in any page.
+Visit the `http://yourdomain.com/sermons` if you have pretty permalinks enabled or `http://yourdomain.com/?post_type=wpfc_sermon` if not. Or you can use the shortcode `[sermons]` in any page or post.
### How do I create a menu link? ###
@@ -102,6 +102,43 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man
2. Sermon Files
## Changelog ##
+### 2.13.0 ###
+* New: Add a simpler way of overriding sermon render
+* New: Add excerpt support (thanks @robertmain!)
+* New: Add read more link to the sermon description (thanks @robertmain!)
+* New: Add revisions support (thanks @robertmain!)
+* New: Add support for custom WP role capabilities (thanks @zSeriesGuy!)
+* New: Add support for sermon password protection
+* New: Add working file for rendering the feed
+* New: Add a tab in settings for controlling the import
+* Change: Add more options to the recent sermons widget
+* Change: Add a way to get sermon's series image
+* Change: Add an option to hide read more when it's not needed
+* Fix: Audio download button glitches sometimes
+* Fix: Custom preacher label in menu lowercased when label is in lowercase
+* Fix: Feed not validating when audio files use SSL
+* Fix: Fix spacing on Divi theme
+* Fix: Image size shortcode argument not working
+* Fix: MP4 video file being detected as YouTube and therefore not working
+* Fix: SB image import breaking when image is local and does not exist on filesystem
+* Fix: Sermon Browser services import
+* Fix: Sermon Details meta not loading under very specific circumstances
+* Fix: Sermons do not appear if published via API and "Date Preached" not set
+* Fix: Sermons not showing in shortcode under certain timezone conditions
+* Fix: Sermons menu title is "All Sermons" instead of "Sermons"
+* Fix: Shortcode pagination not working when "Plain" permalinks are used
+* Fix: Shortcodes showing in iTunes sermon description
+* Fix: Taxonomy image assignment not working
+* Fix: Title not being in the same line, even though there's enough space
+* Dev: Add a filter for filtering sermon image size
+* Dev: Add more hooks
+* Dev: Add PHPUnit configuration
+* Dev: Add support for WordPress attachment ID for sermon audio files
+* Dev: Add WPCS configuration
+* Dev: All terms now support ordering by latest sermon
+* Dev: Deprecate most of old podcasting functions
+* Dev: Refactor widgets code
+
### 2.12.5 ###
* Change: Add Previous/Next sermon navigation
* Change: Add `hide_title` parameter for `[sermon_images]` shortcode
@@ -159,6 +196,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man
### 2.12.0 ###
* New: Add all new views, much more improved
* New: Add more options to sorting shortcode
+* New: Add ability to export/import Sermon Manager data
* Fix: Add more error checking to importing
* Fix: Audio player defaults to "Browser HTML5" when "Disable Sermon Styles" option is checked
* Fix: Plyr sometimes not loading
diff --git a/sermons.php b/sermons.php
index b5f6972..45cd7ae 100755
--- a/sermons.php
+++ b/sermons.php
@@ -3,7 +3,7 @@
* Plugin Name: Sermon Manager for WordPress
* Plugin URI: https://www.wpforchurch.com/products/sermon-manager-for-wordpress/
* Description: Add audio and video sermons, manage speakers, series, and more.
- * Version: 2.12.5
+ * Version: 2.13.0
* Author: WP for Church
* Author URI: https://www.wpforchurch.com/
* Requires at least: 4.5
@@ -11,86 +11,89 @@
*
* Text Domain: sermon-manager-for-wordpress
* Domain Path: /languages/
+ *
+ * @package SM/Core
*/
+// All files must be PHP 5.3 compatible!
defined( 'ABSPATH' ) or die;
-// All files must be PHP 5.3 compatible
-
-// Check the PHP version
+// Check the PHP version.
if ( version_compare( PHP_VERSION, '5.3.0', '<' ) ) {
- if ( is_admin() && ! get_option( 'dismissed-render_php_version_warning', 0 ) ) {
- add_action( 'admin_notices', 'sm_render_php_version_error' );
- }
+ add_action( 'admin_notices', 'sm_render_php_version_error' );
+ /**
+ * Renders the error notice when PHP is less than 5.3
+ *
+ * @since 2.8
+ */
function sm_render_php_version_error() {
?>
-
-
- = // translators: %1$s current PHP version, see msgid "PHP %s", effectively PHP %s
- // translators: %2$s required PHP version, see msgid "PHP %s", effectively PHP %s
- wp_sprintf( esc_html__( 'You are running %1$s, but Sermon Manager requires at least %2$s.', 'sermon-manager-for-wordpress' ), '' . wp_sprintf( esc_html__( 'PHP %s', 'sermon-manager-for-wordpress' ), PHP_VERSION ) . ' ', '' . wp_sprintf( esc_html__( 'PHP %s', 'sermon-manager-for-wordpress' ), '5.3.0' ) . ' ' ); ?>
-
-
+
+
+ PHP %s.
+ // translators: %2$s required PHP version, see msgid "PHP %s", effectively PHP %s .
+ echo wp_sprintf( esc_html__( 'You are running %1$s, but Sermon Manager requires at least %2$s.', 'sermon-manager-for-wordpress' ), '' . wp_sprintf( esc_html__( 'PHP %s', 'sermon-manager-for-wordpress' ), PHP_VERSION ) . ' ', '' . wp_sprintf( esc_html__( 'PHP %s', 'sermon-manager-for-wordpress' ), '5.3.0' ) . ' ' );
+ ?>
+
+
_includes();
- // load translations
+ // Load translations.
add_action( 'after_setup_theme', array( $this, 'load_translations' ) );
- // enqueue scripts & styles
+ // Enqueue scripts & styles.
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) );
add_action( 'wp_footer', array( $this, 'enqueue_scripts_styles' ) );
- // Append custom classes to individual sermons
+ // Append custom classes to individual sermons.
add_filter( 'post_class', array( $this, 'add_additional_sermon_classes' ), 10, 3 );
- // Add Sermon Manager image sizes
+ // Add Sermon Manager image sizes.
add_action( 'after_setup_theme', array( $this, 'add_image_sizes' ) );
- // Fix Sermon ordering
+ // Fix Sermon ordering.
add_action( 'pre_get_posts', array( $this, 'fix_sermons_ordering' ), 90 );
- // no idea... better not touch it for now.
+ // No idea... better not touch it for now.
add_filter( 'sermon-images-disable-public-css', '__return_true' );
- // Handler for dismissing PHP warning notice
- add_action( 'wp_ajax_wpfc_php_notice_handler', array( $this, 'php_notice_handler' ) );
- // Attach to fix WP dates
+ // Attach to fix WP dates.
SM_Dates_WP::hook();
- // Render sermon HTML for search compatibility
+ // Render sermon HTML for search compatibility.
add_action( 'wp_insert_post', array( $this, 'render_sermon_into_content' ), 10, 2 );
- // Remove SB Help from SM pages, since it messes up the formatting
+ // Remove SB Help from SM pages, since it messes up the formatting.
add_action( 'contextual_help', function () {
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
@@ -99,17 +102,21 @@ public function __construct() {
remove_action( 'contextual_help', 'sb_add_contextual_help' );
}
}, 0 );
- // Allow usage of remote URLs for attachments (used for images imported from SE)
+ // Allow usage of remote URLs for attachments (used for images imported from SE).
add_filter( 'wp_get_attachment_url', function ( $url, $attachment_id ) {
- if ( ( $db_url = get_post_meta( $attachment_id, '_wp_attached_file', true ) ) && parse_url( $db_url, PHP_URL_SCHEME ) !== null ) {
+ $db_url = get_post_meta( $attachment_id, '_wp_attached_file', true );
+
+ if ( $db_url && parse_url( $db_url, PHP_URL_SCHEME ) !== null ) {
return $db_url;
}
return $url;
}, 10, 2 );
- // Allows reimport after sermon deletion
+ // Allows reimport after sermon deletion.
add_action( 'before_delete_post', function ( $id ) {
- if ( $GLOBALS['post_type'] !== 'wpfc_sermon' ) {
+ global $post_type;
+
+ if ( 'wpfc_sermon' !== $post_type ) {
return;
}
@@ -122,7 +129,7 @@ public function __construct() {
foreach ( $sermons_array as $offset1 => $value ) {
if ( $value['new_id'] == $id ) {
unset( $sermons_array[ $offset1 ] );
- update_option( $offset0 === 0 ? '_sm_import_se_messages' : '_sm_import_sb_messages', $sermons_array );
+ update_option( 0 === $offset0 ? '_sm_import_se_messages' : '_sm_import_sb_messages', $sermons_array );
return;
}
@@ -130,10 +137,9 @@ public function __construct() {
}
} );
-
- // temporary hook for importing until API is properly done
+ // Temporary hook for importing until API is properly done.
add_action( 'admin_init', function () {
- if ( isset( $_GET['page'] ) && $_GET['page'] === 'sm-import-export' ) {
+ if ( isset( $_GET['page'] ) && 'sm-import-export' === $_GET['page'] ) {
if ( isset( $_GET['doimport'] ) ) {
$class = null;
@@ -154,19 +160,20 @@ public function __construct() {
break;
}
- if ( $class !== null ) {
+ if ( null !== $class ) {
$class->import();
add_action( 'admin_notices', function () {
- if ( ! ! \SermonManager::getOption( 'debug_import' ) ) : ?>
-
-
Debug info:
-
= get_option( 'sm_last_import_info' ) ?: 'No data available.'; ?>
-
+ if ( ! ! \SermonManager::getOption( 'debug_import' ) ) :
+ ?>
+
-
+
-
-
= $value ?>
executed.
-
+
$functions ) {
foreach ( $functions as $function ) {
if ( ! get_option( 'wp_sm_updater_' . $function . '_done', 0 ) ) {
@@ -208,9 +215,9 @@ public function __construct() {
call_user_func( $function );
?>
-
-
= $function ?>
executed.
-
+
-
-
All update functions have already been executed.
-
+
+
All update functions have already been executed.
+
get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", 'wpfc_sermon' ) );
+ // All sermons.
+ $sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE `post_type` = %s", 'wpfc_sermon' ) );
foreach ( $sermons as $sermon ) {
- $sermon_ID = $sermon->ID;
+ $sermon_id = $sermon->ID;
- if ( $value === 11 ) {
- $sm->render_sermon_into_content( $sermon_ID, null, true );
+ if ( 11 === $value ) {
+ $sm->render_sermon_into_content( $sermon_id, null, true );
} else {
- $wpdb->query( "UPDATE $wpdb->posts SET `post_content` = '' WHERE `ID` = $sermon_ID" );
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET `post_content` = '' WHERE `ID` = %d", $sermon_id ) );
}
}
@@ -260,105 +267,55 @@ public function __construct() {
return $value;
} );
-
- add_action( 'sm_admin_settings_sanitize_option_post_excerpt_enabled', function ( $value ) {
- $value = intval( $value );
-
- if ( $value >= 10 ) {
- global $wpdb, $skip_excerpt_check;
-
- $skip_excerpt_check = true;
-
- $sm = SermonManager::get_instance();
-
- // All sermons
- $sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", 'wpfc_sermon' ) );
-
- foreach ( $sermons as $sermon ) {
- $sermon_ID = $sermon->ID;
-
- if ( $value === 11 ) {
- $sm->render_sermon_into_content( $sermon_ID, null, true );
- } else {
- $wpdb->query( "UPDATE $wpdb->posts SET `post_excerpt` = '' WHERE `ID` = $sermon_ID" );
- }
- }
-
- $skip_excerpt_check = false;
-
- $value = intval( substr( $value, 1 ) );
- }
-
- return $value;
- } );
}
/**
- * Include Sermon Manager files
+ * Include Sermon Manager files.
*
* @return void
*/
private function _includes() {
/**
- * Files to include on frontend and backend
+ * General includes.
*/
- $includes = array(
- 'includes/class-sm-autoloader.php', // Autoloader
- 'includes/sm-core-functions.php', // Core Sermon Manager functions
- 'includes/class-sm-dates.php', // Dates operations
- 'includes/class-sm-dates-wp.php', // Attach to WP filters
- 'includes/class-sm-api.php', // API
- 'includes/class-sm-post-types.php', // Register post type, taxonomies, etc
- 'includes/class-sm-install.php', // Install and update functions
- 'includes/sm-deprecated-functions.php', // Deprecated SM functions
- 'includes/sm-formatting-functions.php', // Data formatting
- 'includes/sm-cmb-functions.php', // CMB2 Meta Fields functions
- 'includes/taxonomy-images/taxonomy-images.php', // Images for Custom Taxonomies
- 'includes/entry-views.php', // Entry Views Tracking
- 'includes/shortcodes.php', // Shortcodes
- 'includes/widgets.php', // Widgets
- 'includes/sm-template-functions.php', // Template functions
- 'includes/podcast-functions.php', // Podcast Functions
- 'includes/helper-functions.php', // Global Helper Functions
- );
+ include SM_PATH . 'includes/class-sm-autoloader.php'; // Autoloader.
+ include SM_PATH . 'includes/sm-core-functions.php'; // Core Sermon Manager functions.
+ include SM_PATH . 'includes/class-sm-dates.php'; // Dates operations.
+ include SM_PATH . 'includes/class-sm-dates-wp.php'; // Attach to WP filters.
+ include SM_PATH . 'includes/class-sm-api.php'; // API.
+ include SM_PATH . 'includes/class-sm-post-types.php'; // Register post type, taxonomies, etc.
+ include SM_PATH . 'includes/class-sm-install.php'; // Install and update functions.
+ include SM_PATH . 'includes/class-sm-roles.php'; // Adds roles support.
+ include SM_PATH . 'includes/sm-deprecated-functions.php'; // Deprecated SM functions.
+ include SM_PATH . 'includes/sm-formatting-functions.php'; // Data formatting.
+ include SM_PATH . 'includes/vendor/taxonomy-images/taxonomy-images.php'; // Images for Custom Taxonomies.
+ include SM_PATH . 'includes/vendor/entry-views.php'; // Entry Views Tracking.
+ include SM_PATH . 'includes/class-sm-shortcodes.php'; // Shortcodes.
+ include SM_PATH . 'includes/class-sm-widget-recent-sermons.php'; // Recent sermons widget.
+ include SM_PATH . 'includes/sm-template-functions.php'; // Template functions.
+ include SM_PATH . 'includes/sm-podcast-functions.php'; // Podcast Functions.
/**
- * Admin only includes
+ * Admin only includes.
*/
- $admin_includes = array(
- 'includes/admin/class-sm-admin.php', // Admin init class
- 'includes/admin-functions.php', // General Admin area functions - todo: refactor before 2.9
- 'includes/CMB2/init.php', // Metaboxes
- );
-
- // Load files
- foreach ( $includes as $file ) {
- if ( file_exists( SM_PATH . $file ) ) {
- require_once SM_PATH . $file;
- }
- }
-
- // Load admin files
if ( is_admin() ) {
- foreach ( $admin_includes as $file ) {
- if ( file_exists( SM_PATH . $file ) ) {
- require_once SM_PATH . $file;
- }
- }
+ include SM_PATH . 'includes/admin/class-sm-admin.php'; // Admin init class.
+ include SM_PATH . 'includes/admin/sm-cmb-functions.php'; // CMB2 Meta Fields functions.
+ include SM_PATH . 'includes/vendor/CMB2/init.php'; // Metaboxes.
}
}
/**
* Instead of loading options variable each time in every code snippet, let's have it in one place.
*
- * @param string $name Option name
- * @param string $default Default value to return if option is not set (defaults to empty string)
+ * @param string $name Option name.
+ * @param string $default Default value to return if option is not set (defaults to empty string).
*
* @return mixed Returns option value or an empty string if it doesn't exist. Just like WP does.
*/
public static function getOption( $name = '', $default = '' ) {
if ( ! class_exists( 'SM_Admin_Settings' ) ) {
- include_once 'includes/admin/class-sm-admin-settings.php';
+ include_once SM_PATH . 'includes/admin/class-sm-admin-settings.php';
}
return SM_Admin_Settings::get_option( $name, $default );
@@ -378,22 +335,22 @@ public static function get_instance() {
}
/**
- * Saves whole Sermon HTML markup into post content for better search compatibility
+ * Saves whole Sermon HTML markup into post content for better search compatibility.
*
- * @param int $post_ID
- * @param WP_Post $post Post object
- * @param bool $skip_check Disables check of "SM_SAVING_POST" constant
+ * @param int $post_ID Post ID.
+ * @param WP_Post $post Post object.
+ * @param bool $skip_check Disables check of "SM_SAVING_POST" constant.
*
* @since 2.8
*/
public function render_sermon_into_content( $post_ID = 0, $post = null, $skip_check = false ) {
- global $wpdb, $skip_excerpt_check, $skip_content_check;
+ global $wpdb, $skip_content_check;
- if ( $post === null ) {
+ if ( null === $post ) {
$post = get_post( $post_ID );
}
- if ( $post->post_type !== 'wpfc_sermon' ) {
+ if ( 'wpfc_sermon' !== $post->post_type ) {
return;
}
@@ -405,13 +362,16 @@ public function render_sermon_into_content( $post_ID = 0, $post = null, $skip_ch
}
}
- $content = '';
+ $content = '';
+ $bible_passage = get_post_meta( $post_ID, 'bible_passage', true );
+ $has_preachers = has_term( '', 'wpfc_preacher', $post );
+ $has_series = has_term( '', 'wpfc_sermon_series', $post );
- if ( $bible_passage = get_post_meta( $post_ID, 'bible_passage', true ) ) {
+ if ( $bible_passage ) {
$content .= __( 'Bible Text:', 'sermon-manager-for-wordpress' ) . ' ' . $bible_passage;
}
- if ( $has_preachers = has_term( '', 'wpfc_preacher', $post ) ) {
+ if ( $has_preachers ) {
if ( $bible_passage ) {
$content .= ' | ';
}
@@ -420,7 +380,7 @@ public function render_sermon_into_content( $post_ID = 0, $post = null, $skip_ch
$content .= strip_tags( get_the_term_list( $post->ID, 'wpfc_preacher', '', ', ', '' ) );
}
- if ( $has_series = has_term( '', 'wpfc_sermon_series', $post ) ) {
+ if ( $has_series ) {
if ( $has_preachers ) {
$content .= ' | ';
}
@@ -429,74 +389,52 @@ public function render_sermon_into_content( $post_ID = 0, $post = null, $skip_ch
$description = strip_tags( trim( get_post_meta( $post->ID, 'sermon_description', true ) ) );
- if ( $description !== '' ) {
+ if ( '' !== $description ) {
$content .= PHP_EOL . PHP_EOL;
$content .= $description;
}
/**
- * Allows to modify sermon content that will be saved as "post_content"
+ * Allows to modify sermon content that will be saved as "post_content".
*
- * @param string $content Textual content (no HTML)
- * @param int $post_ID ID of the sermon
- * @param WP_Post $post Sermon post object
- * @param bool $skip_check Basically, a way to identify if the function is being
- * executed from the update function or not
+ * @param string $content Textual content (no HTML).
+ * @param int $post_ID ID of the sermon.
+ * @param WP_Post $post Sermon post object.
+ * @param bool $skip_check Basically, a way to identify if the function is being executed from the update function or not.
*
* @since 2.11.0
*/
- $content = apply_filters( "sm_sermon_post_content", $content, $post_ID, $post, $skip_check );
+ $content = apply_filters( 'sm_sermon_post_content', $content, $post_ID, $post, $skip_check );
$content = apply_filters( "sm_sermon_post_content_$post_ID", $content, $post_ID, $post, $skip_check );
- $excerpt = ! $content ? '' : wp_trim_excerpt( $content );
-
- /**
- * Allows to modify sermon content that will be saved as "post_excerpt"
- *
- * @param string $excerpt Textual content (no HTML), limited to 55 words by default
- * @param int $post_ID ID of the sermon
- * @param WP_Post $post Sermon post object
- * @param bool $skip_check Basically, a way to identify if the function is being
- * executed from the update function or not
- *
- * @since 2.11.0
- */
- $excerpt = apply_filters( "sm_sermon_post_excerpt", $excerpt, $post_ID, $post, $skip_check );
- $excerpt = apply_filters( "sm_sermon_post_excerpt_$post_ID", $excerpt, $post_ID, $post, $skip_check );
-
if ( ! $skip_content_check ) {
if ( ! \SermonManager::getOption( 'post_content_enabled', 1 ) ) {
$content = '';
}
}
- if ( ! $skip_excerpt_check ) {
- if ( ! \SermonManager::getOption( 'post_excerpt_enabled', 1 ) ) {
- $excerpt = '';
- }
- }
-
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET `post_content` = '%s', `post_excerpt` = '%s' WHERE `ID` = $post_ID", array(
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET `post_content` = %s WHERE `ID` = %s", array(
$content,
- $excerpt,
+ $post_ID,
) ) );
}
/**
- * Fixes Sermons ordering. Uses `sermon_date` meta instead of sermon's published date
+ * Fixes Sermons ordering. Uses `sermon_date` meta instead of sermon's published date.
*
- * @param WP_Query $query
+ * @param WP_Query $query The query.
*
* @return void
*/
public static function fix_sermons_ordering( $query ) {
if ( ! is_admin() && ( $query->is_main_query() ) ) {
- if ( is_post_type_archive( 'wpfc_sermon' ) ||
- is_tax( 'wpfc_preacher' ) ||
- is_tax( 'wpfc_sermon_topics' ) ||
- is_tax( 'wpfc_sermon_series' ) ||
- is_tax( 'wpfc_bible_book' )
- ) {
+ if ( is_post_type_archive( array(
+ 'wpfc_sermon',
+ 'wpfc_preacher',
+ 'wpfc_sermon_topics',
+ 'wpfc_sermon_series',
+ 'wpfc_bible_book',
+ ) ) ) {
$query->set( 'meta_key', 'sermon_date' );
$query->set( 'meta_value_num', time() );
$query->set( 'meta_compare', '<=' );
@@ -525,27 +463,27 @@ public static function enqueue_scripts_styles() {
return;
}
- if ( ! ( defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ||
- 'wpfc_sermon' === get_post_type() ||
- is_post_type_archive( 'wpfc_sermon' ) )
+ wp_register_script( 'wpfc-sm-fb-player', SM_URL . 'assets/vendor/js/facebook-video.js', array(), SM_VERSION );
+ wp_register_script( 'wpfc-sm-plyr', SM_URL . 'assets/vendor/js/plyr' . ( ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) ? '' : '.min' ) . '.js', array(), SM_VERSION, \SermonManager::getOption( 'player_js_footer' ) );
+ wp_register_script( 'wpfc-sm-verse-script', SM_URL . 'assets/vendor/js/verse.js', array(), SM_VERSION );
+ wp_register_style( 'wpfc-sm-styles', SM_URL . 'assets/css/sermon.min.css', array(), SM_VERSION );
+ wp_register_style( 'wpfc-sm-plyr-css', SM_URL . 'assets/vendor/css/plyr.min.css', array(), SM_VERSION );
+
+ if ( ! ( defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) || 'wpfc_sermon' === get_post_type() || is_post_type_archive( 'wpfc_sermon' ) )
) {
return;
}
if ( ! \SermonManager::getOption( 'css' ) ) {
- wp_enqueue_style( 'wpfc-sm-styles', SM_URL . 'assets/css/sermon.min.css', array(), SM_VERSION );
+ wp_enqueue_style( 'wpfc-sm-styles' );
wp_enqueue_style( 'dashicons' );
- wp_enqueue_script( 'wpfc-sm-additional_classes', SM_URL . 'assets/js/additional_classes.js', array(), SM_VERSION, true );
-
- // load theme-specific styling, if there's any
+ // Load theme-specific styling, if there's any.
if ( file_exists( SM_PATH . 'assets/css/theme-specific/' . get_option( 'template' ) . '.css' ) ) {
wp_enqueue_style( 'wpfc-sm-style-' . get_option( 'template' ), SM_URL . 'assets/css/theme-specific/' . get_option( 'template' ) . '.css', array( 'wpfc-sm-styles' ), SM_VERSION );
}
}
- wp_register_script( 'wpfc-sm-fb-player', SM_URL . 'assets/js/facebook-video.js', array(), SM_VERSION );
-
switch ( \SermonManager::getOption( 'player' ) ) {
case 'mediaelement':
wp_enqueue_style( 'wp-mediaelement' );
@@ -553,27 +491,27 @@ public static function enqueue_scripts_styles() {
break;
case 'plyr':
- wp_enqueue_script( 'wpfc-sm-plyr', SM_URL . 'assets/js/plyr' . ( ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) ? '' : '.min' ) . '.js', array(), SM_VERSION, \SermonManager::getOption( 'player_js_footer' ) );
- wp_enqueue_style( 'wpfc-sm-plyr-css', SM_URL . 'assets/css/plyr.min.css', array(), SM_VERSION );
+ wp_enqueue_script( 'wpfc-sm-plyr' );
+ wp_enqueue_style( 'wpfc-sm-plyr-css' );
wp_add_inline_script( 'wpfc-sm-plyr', "window.addEventListener('DOMContentLoaded',function(){var players=plyr.setup(document.querySelectorAll('.wpfc-sermon-player,.wpfc-sermon-video-player'),{\"debug\": " . ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ? 'true' : 'false' ) . "});for(var p in players){if(players.hasOwnProperty(p)){players[p].on('loadedmetadata ready',function(event){if(typeof this.firstChild.dataset.plyr_seek !== 'undefined'){var instance=event.detail.plyr;instance.seek(parseInt(this.firstChild.dataset.plyr_seek));}});}}})" );
break;
}
if ( ! \SermonManager::getOption( 'verse_popup' ) ) {
- wp_enqueue_script( 'wpfc-sm-verse-script', SM_URL . 'assets/js/verse.js', array(), SM_VERSION );
-
- // get options for JS
- $bible_version = \SermonManager::getOption( 'verse_bible_version' );
-
- if ( strpos( get_locale(), 'es_' ) === false &&
- in_array( $bible_version, array(
- 'LBLA95',
- 'NBLH',
- 'NVI',
- 'RVR60',
- 'RVA',
- ) ) ) {
+ wp_enqueue_script( 'wpfc-sm-verse-script' );
+
+ // Get options for JS.
+ $bible_version = \SermonManager::getOption( 'verse_bible_version' );
+ $bible_versions = array(
+ 'LBLA95',
+ 'NBLH',
+ 'NVI',
+ 'RVR60',
+ 'RVA',
+ );
+
+ if ( strpos( get_locale(), 'es_' ) === false && in_array( $bible_version, $bible_versions ) ) {
$bible_version = 'ESV';
}
@@ -583,7 +521,7 @@ public static function enqueue_scripts_styles() {
) );
}
- // do not enqueue twice
+ // Do not enqueue twice.
define( 'SM_SCRIPTS_STYLES_ENQUEUED', true );
}
@@ -591,14 +529,14 @@ public static function enqueue_scripts_styles() {
* Append the terms of Sermon Manager taxonomies to the list
* of sermon (post) classes generated by post_class().
*
- * @param array $classes An array of existing post classes
- * @param array $class An array of additional classes added to the post (not needed)
- * @param int $post_id The post ID
+ * @param array $classes An array of existing post classes.
+ * @param array $class An array of additional classes added to the post (not needed).
+ * @param int $post_id The post ID.
*
- * @return array Modified class list
+ * @return array Modified class list.
*/
public static function add_additional_sermon_classes( $classes, $class, $post_id ) {
- if ( get_post_type( $post_id ) !== 'wpfc_sermon' ) {
+ if ( 'wpfc_sermon' !== get_post_type( $post_id ) ) {
return $classes;
}
@@ -659,42 +597,16 @@ public static function add_image_sizes() {
add_image_size( 'sermon_wide', 940, 350, true );
}
}
-
- /**
- * Renders the notice when the user is not using correct PHP version
- */
- public static function render_php_version_warning() {
- ?>
-
-
- PHP %s, but Sermon Manager recommends at least PHP %s . If you encounter issues, update PHP to a recommended version and check if they are still there.", PHP_VERSION, '5.6.0' ); ?>
-
-
- post &&
- false !== strpos( $wp_query->post->post_content, '[sermons' ) ) {
+ if ( get_query_var( 'paged' ) && $wp_query->post && false !== strpos( $wp_query->post->post_content, '[sermons' ) ) {
return false;
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 0000000..1333835
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,31 @@
+assertTrue( true );
+ }
+}
diff --git a/views/archive-wpfc_sermon.php b/views/archive-wpfc_sermon.php
index c9c93eb..18411b0 100644
--- a/views/archive-wpfc_sermon.php
+++ b/views/archive-wpfc_sermon.php
@@ -1,23 +1,32 @@
-
+
-/partials/content-sermon-archive.php`
+ * - `/wp-content/themes//template-parts/content-sermon-archive.php`
+ * - `/wp-content/themes//content-sermon-archive.php`
+ *
+ * That will ensure that your changes are not deleted on plugin update.
+ *
+ * Sometimes, we need to edit this file to add new features or to fix some bugs, and when we do so, we will modify the
+ * changelog in this header comment.
+ *
+ * @package SermonManager\Views\Partials
+ *
+ * @since 2.13.0 - added
+ */
+
+global $post;
+
+$args = ! empty( $args ) ? $args : array(
+ 'image_size' => 'post-thumbnail',
+);
+
+?>
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID, 'sermon_description', true ), 30 ); ?>
+
+
+
+ ID, 'sermon_description', true ) ) > 30 ) : ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/views/partials/content-sermon-attachments.php b/views/partials/content-sermon-attachments.php
new file mode 100644
index 0000000..265d5f6
--- /dev/null
+++ b/views/partials/content-sermon-attachments.php
@@ -0,0 +1,42 @@
+/partials/content-sermon-attachments.php`
+ * - `/wp-content/themes//template-parts/content-sermon-attachments.php`
+ * - `/wp-content/themes//content-sermon-attachments.php`
+ *
+ * That will ensure that your changes are not deleted on plugin update.
+ *
+ * Sometimes, we need to edit this file to add new features or to fix some bugs, and when we do so, we will modify the
+ * changelog in this header comment.
+ *
+ * @package SermonManager\Views\Partials
+ *
+ * @since 2.13.0 - added
+ */
+
+global $post;
+?>
+
+
diff --git a/views/partials/content-sermon-filtering.php b/views/partials/content-sermon-filtering.php
new file mode 100644
index 0000000..7754239
--- /dev/null
+++ b/views/partials/content-sermon-filtering.php
@@ -0,0 +1,90 @@
+/partials/content-sermon-filtering.php`
+ * - `/wp-content/themes//template-parts/content-sermon-filtering.php`
+ * - `/wp-content/themes//content-sermon-filtering.php`
+ *
+ * That will ensure that your changes are not deleted on plugin update.
+ *
+ * Sometimes, we need to edit this file to add new features or to fix some bugs, and when we do so, we will modify the
+ * changelog in this header comment.
+ *
+ * @package SermonManager\Views\Partials
+ *
+ * @since 2.13.0 - added
+ */
+
+global $post;
+
+if ( ! empty( $GLOBALS['wpfc_partial_args'] ) ) {
+ foreach ( $GLOBALS['wpfc_partial_args'] as $variable => $data ) {
+ $$variable = $data;
+ }
+}
+
+foreach (
+ array(
+ 'action',
+ 'filters',
+ 'visibility_mapping',
+ 'args',
+ ) as $required_variable
+) {
+ if ( ! isset( $$required_variable ) ) {
+ echo 'Sermon Manager : Partial "' . str_replace( '.php', '', basename( __FILE__ ) ) . ' " loaded incorrectly.
';
+
+ return;
+ }
+}
+
+?>
+
\ No newline at end of file
diff --git a/views/partials/content-sermon-single.php b/views/partials/content-sermon-single.php
new file mode 100644
index 0000000..1603714
--- /dev/null
+++ b/views/partials/content-sermon-single.php
@@ -0,0 +1,143 @@
+/partials/content-sermon-single.php`
+ * - `/wp-content/themes//template-parts/content-sermon-single.php`
+ * - `/wp-content/themes//content-sermon-single.php`
+ *
+ * That will ensure that your changes are not deleted on plugin update.
+ *
+ * Sometimes, we need to edit this file to add new features or to fix some bugs, and when we do so, we will modify the
+ * changelog in this header comment.
+ *
+ * @package SermonManager\Views\Partials
+ *
+ * @since 2.13.0 - added
+ */
+
+global $post;
+?>
+
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID ) ) : ?>
+
+
+ :
+ ID, 'wpfc_sermon_topics' ); ?>
+
+
+
+
+
+
+
+
>
+
+
+
+
+
>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/views/partials/wrapper-end.php b/views/partials/wrapper-end.php
index 4e8481f..abf53b8 100644
--- a/views/partials/wrapper-end.php
+++ b/views/partials/wrapper-end.php
@@ -1,34 +1,41 @@
- ';
if ( is_archive() ) {
get_sidebar();
}
break;
- case 'twentytwelve' :
+ case 'twentytwelve':
echo '';
get_sidebar();
break;
- case 'twentythirteen' :
+ case 'twentythirteen':
echo '';
break;
- case 'twentyfourteen' :
+ case 'twentyfourteen':
echo '';
get_sidebar( 'content' );
break;
- case 'twentyfifteen' :
+ case 'twentyfifteen':
get_sidebar();
echo '';
break;
- case 'twentysixteen' :
+ case 'twentysixteen':
echo '';
get_sidebar();
break;
- case 'twentyseventeen' :
+ case 'twentyseventeen':
echo '';
get_sidebar();
break;
@@ -47,7 +54,22 @@
get_sidebar();
echo '';
break;
- default :
+ case 'wpfc-morgan':
+ echo '';
+ get_sidebar( 'sermon' );
+ get_footer();
+ break;
+ case 'bb-theme';
+ echo '';
+ get_sidebar();
+ echo '';
+ break;
+ case 'bb-theme-builder';
+ echo '';
+ get_sidebar();
+ echo '';
+ break;
+ default:
ob_start();
get_sidebar();
$sidebar = ob_get_clean();
diff --git a/views/partials/wrapper-start.php b/views/partials/wrapper-start.php
index bb2bf5f..0519d1c 100644
--- a/views/partials/wrapper-start.php
+++ b/views/partials/wrapper-start.php
@@ -1,39 +1,55 @@
-';
break;
- case 'twentytwelve' :
+ case 'twentytwelve':
echo '
';
break;
- case 'twentythirteen' :
+ case 'twentythirteen':
echo '
';
break;
- case 'twentyfourteen' :
+ case 'twentyfourteen':
echo '
';
break;
- case 'twentyfifteen' :
+ case 'twentyfifteen':
echo '
';
break;
- case 'twentysixteen' :
+ case 'twentysixteen':
echo '
';
break;
- case 'twentyseventeen' :
+ case 'twentyseventeen':
echo '';
break;
case 'Divi':
echo '';
break;
- case 'salient' :
+ case 'salient':
echo '';
break;
- case 'Avada' :
+ case 'Avada':
echo '
';
break;
- default :
+ case 'wpfc-morgan':
+ echo '
';
+ break;
+ case 'bb-theme';
+ echo '
';
+ break;
+ case 'bb-theme-builder';
+ echo '
';
+ break;
+ default:
echo apply_filters( 'sm_templates_wrapper_start', '
' );
break;
}
diff --git a/views/single-wpfc_sermon.php b/views/single-wpfc_sermon.php
index 7160bb1..8bd6af9 100755
--- a/views/single-wpfc_sermon.php
+++ b/views/single-wpfc_sermon.php
@@ -1,17 +1,32 @@
-
+
@@ -6,19 +14,21 @@
-
+
@@ -6,19 +14,21 @@
-
+
@@ -6,19 +14,21 @@
-
+
@@ -6,19 +14,21 @@
-
+
@@ -6,19 +14,21 @@
- 'wpfc_sermon',
- 'posts_per_page' => - 1,
+ 'posts_per_page' => intval( \SermonManager::getOption( 'podcasts_per_page' ) ) ?: 10,
'meta_key' => 'sermon_date',
'meta_value_num' => time(),
'meta_compare' => '<=',
'orderby' => 'meta_value_num',
+ 'paged' => isset( $_GET['paged'] ) ? intval( $_GET['paged'] ) : 1,
+ 'meta_query' => array(
+ 'relation' => 'AND',
+ array(
+ 'key' => 'sermon_audio',
+ 'compare' => 'EXISTS',
+ ),
+ array(
+ 'key' => 'sermon_audio',
+ 'value' => '',
+ 'compare' => '!=',
+ ),
+ ),
);
+
+/**
+ * Allow filtering by taxonomies.
+ *
+ * Example: To filter sermons preached by John Doe, and are in series named Jesus, just execute the following query:
+ * "https://www.example.com/?post_type=wpfc_sermon&wpfc_preacher=john-doe&wpfc_sermon_series=jesus"
+ */
+foreach (
+ array(
+ 'wpfc_preacher',
+ 'wpfc_sermon_series',
+ 'wpfc_sermon_topics',
+ 'wpfc_bible_book',
+ 'wpfc_service_type',
+ ) as $taxonomy
+) {
+ if ( isset( $_GET[ $taxonomy ] ) ) {
+ $terms = $_GET[ $taxonomy ];
+ $args['tax_query'] = ! empty( $args['tax_query'] ) ? $args['tax_query'] : array();
+ $args['tax_query'][] = array(
+ 'taxonomy' => $taxonomy,
+ 'field' => is_numeric( $terms ) ? 'term_id' : 'slug',
+ 'terms' => is_numeric( $terms ) ? intval( $terms ) : false !== strpos( $terms, ',' ) ? array_walk( explode( ',', $terms ), 'sanitize_title' ) : sanitize_title( $terms ),
+ );
+
+ if ( count( $args['tax_query'] ) > 1 ) {
+ $args['tax_query']['relation'] = 'AND';
+ }
+ }
+}
+
+/**
+ * Allows to filter the sermon feed query arguments.
+ *
+ * @param array $args WP_Query arguments.
+ *
+ * @since 2.13.0
+ */
+$args = apply_filters( 'sermon_feed_query_args', $args );
+
$sermon_podcast_query = new WP_Query( $args );
-?>= '' ?>
+$categories = array(
+ '0' => '',
+ '1' => 'Buddhism',
+ '2' => 'Christianity',
+ '3' => 'Hinduism',
+ '4' => 'Islam',
+ '5' => 'Judaism',
+ '6' => 'Other',
+ '7' => 'Spirituality',
+);
+
+$title = esc_html( \SermonManager::getOption( 'title' ) ) ?: get_wp_title_rss();
+$link = esc_url( \SermonManager::getOption( 'website_link' ) ) ?: get_bloginfo_rss( 'url' );
+$atom_link = ( ! empty( $_SERVER['HTTPS'] ) ? 'https://' : 'http://' ) . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
+$description = esc_html( \SermonManager::getOption( 'description' ) ) ?: get_bloginfo_rss( 'description' );
+$language = esc_html( \SermonManager::getOption( 'language' ) ) ?: get_bloginfo_rss( 'language' );
+$last_sermon_date = get_post_meta( $sermon_podcast_query->posts[0]->ID, 'sermon_date', true ) ?: null;
+$copyright = html_entity_decode( esc_html( \SermonManager::getOption( 'copyright' ) ), ENT_COMPAT, 'UTF-8' );
+$subtitle = esc_html( \SermonManager::getOption( 'itunes_subtitle' ) );
+$author = esc_html( \SermonManager::getOption( 'itunes_author' ) );
+$summary = str_replace( ' ', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) ) : stripslashes( wp_filter_nohtml_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) );
+$owner_name = esc_html( \SermonManager::getOption( 'itunes_owner_name' ) );
+$owner_email = esc_html( \SermonManager::getOption( 'itunes_owner_email' ) );
+$cover_image_url = esc_url( \SermonManager::getOption( 'itunes_cover_image' ) );
+$subcategory = esc_attr( $categories[ \SermonManager::getOption( 'itunes_sub_category' ) ] );
+
+?>
- >
-
-
-
-
-
-
-
-
- have_posts() ) : while ( $sermon_podcast_query->have_posts() ) : $sermon_podcast_query->the_post(); ?>
-
- ID, 'sermon_audio', true ) !== '' ) : ?>
- -
-
-
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
+>
+
+
+
+
+
+
+
+
+ hourly
+ 1
+
+
+
+
+
+
+
+
+ no
+
+
+
+
+
+
+
+ have_posts() ) :
+ while ( $sermon_podcast_query->have_posts() ) :
+ $sermon_podcast_query->the_post();
+ global $post;
+
+ $audio_id = get_post_meta( $post->ID, 'sermon_audio_id', true );
+ $audio_url = $audio_id ? wp_get_attachment_url( intval( $audio_id ) ) : get_post_meta( $post->ID, 'sermon_audio', true );
+ $audio_raw = str_ireplace( 'https://', 'http://', $audio_url );
+ $audio_p = strrpos( $audio_raw, '/' ) + 1;
+ $audio_raw = urldecode( $audio_raw );
+ $audio = substr( $audio_raw, 0, $audio_p ) . rawurlencode( substr( $audio_raw, $audio_p ) );
+ $speakers = strip_tags( get_the_term_list( $post->ID, 'wpfc_preacher', '', ' & ', '' ) );
+ $speakers_terms = get_the_terms( $post->ID, 'wpfc_preacher' );
+ $speaker = $speakers_terms ? $speakers_terms[0]->name : '';
+ $series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) );
+ $topics = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ) );
+ $post_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
+ $post_image = str_ireplace( 'https://', 'http://', ! empty( $post_image['0'] ) ? $post_image['0'] : '' );
+ $audio_duration = get_post_meta( $post->ID, '_wpfc_sermon_duration', true ) ?: '0:00';
+ $audio_file_size = get_post_meta( $post->ID, '_wpfc_sermon_size', 'true' ) ?: 0;
+ $description = strip_shortcodes( get_post_meta( 'sermon_description' ) );
+ $description = str_replace( ' ', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) );
+
+ // Fix for relative audio file URLs.
+ if ( substr( $audio, 0, 1 ) === '/' ) {
+ $audio = site_url( $audio );
+ }
+
+ if ( \SermonManager::getOption( 'podtrac' ) ) {
+ $audio = 'http://dts.podtrac.com/redirect.mp3/' . esc_url( preg_replace( '#^https?://#', '', $audio ) );
+ } else {
+ // As per RSS 2.0 spec, the enclosure URL must be HTTP only:
+ // http://www.rssboard.org/rss-specification#ltenclosuregtSubelementOfLtitemgt .
+ $audio = preg_replace( '/^https:/i', 'http:', $audio );
+ }
+ ?>
+
+ -
+
+
-
+
+
+
+
+ ]]>
+
+
+
+ ]]>
+ ]]>
+
+
+
+
+
-
- ]]>
-
-
-
- asd]]>
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+