Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Content Based on Month
- Description: Displays 1 of 2 sets of content every 2 months and switches automatically. Also provides an expiration shortcode.
- Author: Onlineth
- Version: Beta
- */
- /*
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- */
- function content_set1( $atts, $contenttext1 = null ) {
- $date = date('F');
- switch ($date) {
- case 'January':
- case 'Febuary':
- case 'May':
- case 'June':
- case 'September':
- case 'October':
- return $contenttext1;
- }
- }
- function content_set2( $atts, $contenttext2 = null ) {
- $date = date('F');
- switch ($date) {
- case 'March':
- case 'April':
- case 'July':
- case 'August':
- case 'November':
- case 'December':
- return $contenttext2;
- }
- }
- function lastdaymonth(){
- $month = date('m');
- if ($month % 2 == 0) {
- return (new DateTime())->format("m/d/Y");
- } else {
- return (new DateTime("+1 month"))->format("m/d/Y");
- }
- }
- add_shortcode('expiration', 'lastdaymonth');
- add_shortcode('content1', 'content_set1');
- add_shortcode('content2', 'content_set2');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement