> 2
+<form method="get">
3
+    <div class='row'>
4
+        <!--
5
+            {{ filter.form.fields }} -->
6
+    {% for f0  in filter.form %}
7
+        <div class='col-md-3'>
8
+            {{ f0 | as_crispy_field}}  
9
+        </div>
10
+    {% endfor %}
11
+    </div>
12
+    <input type="submit" class='btn btn-primary' value='Search'/>
13
+</form>

+ 25 - 0
app/fruit/templates/fruit/inbox_form.html

@@ -0,0 +1,25 @@
1
+{% extends "fruit/inbox_index.html" %}
2
+{% load static %}
3
+{% load crispy_forms_tags %}
4
+{% load django_bootstrap_breadcrumbs %}
5
+
6
+{% block header %}            
7
+{{ form.media  }}
8
+{% endblock %}
9
+
10
+{% block breadcrumbs %}
11
+    {{ block.super }}
12
+    {% breadcrumb "Inbox Form" "fruit:inbox_edit" form.instance.pk %}
13
+{% endblock %}
14
+
15
+{% block store_main %}
16
+<h2>Inbox Form</h2>
17
+<form  method="post" enctype="multipart/form-data">
18
+    {% csrf_token %}
19
+    {{ form | crispy  }}
20
+    <br>
21
+    <input type='submit' class='btn btn-primary' value="Update" />
22
+
23
+</form>
24
+
25
+{% endblock %}

+ 50 - 0
app/fruit/templates/fruit/inbox_index.html

@@ -0,0 +1,50 @@
1
+{% extends "fruit/mystore.html" %}
2
+{% load static %}
3
+{% load crispy_forms_tags %}
4
+
5
+{% block header %}            
6
+{% endblock %}
7
+
8
+{% load django_bootstrap_breadcrumbs %}
9
+{% block breadcrumbs %}
10
+    {{ block.super }}
11
+    {% breadcrumb "Inboxes" "fruit:inbox_index" %}
12
+{% endblock %}
13
+
14
+{% block store_main %}
15
+<!--
16
+<a  class='btn btn-primary' href="{% url "fruit:product_create" %}">Create Product</a> -->
17
+<hr>
18
+<h2>
19
+    Inbox Index</h2>
20
+{% include "fruit/_searchcenter.html" %}
21
+<hr>
22
+<table class='table table-borded table-striped'>
23
+    <thead>
24
+        <tr>
25
+            <th>ID</th>
26
+            <th>Store</th>
27
+            <th>Product</th>
28
+            <th>Buyer</th>
29
+            <th>Subject</th>
30
+            <th>Body</th>
31
+            <th>Status</th>
32
+            <th>Created At</th></tr>
33
+    </thead>
34
+    <tbody>
35
+{% for p in page_obj %}
36
+        <tr>
37
+            <td><a href="{% url "fruit:inbox_edit" pk=p.pk %}">{{ p.id }}</a></td><td>{{ p.product }}</td>
38
+            <td>{{ p.store}}</td>
39
+            <td>{{ p.product }}</td>
40
+            <td>{{ p.buyer }}</td>
41
+            <td>{{ p.subject }}</td>
42
+            <td>{{ p.body }}</td>
43
+            <td>{{ p.status }}</td>
44
+            <td>{{ p.created_at }}</td>
45
+        </tr>
46
+{% endfor %}
47
+    </tbody>
48
+</table>
49
+{% include "fruit/_paging.html" %}
50
+{% endblock %}

+ 12 - 3
app/fruit/templates/fruit/mystore.html

@@ -1,6 +1,7 @@
1 1
 {% extends "front/base.html" %}
2 2
 {% load static %}
3 3
 {% load crispy_forms_tags %}
4
+{% load django_bootstrap_breadcrumbs %}
4 5
 
5 6
 {% block header %}            
6 7
 {{ storeForm.media  }}
@@ -8,21 +9,29 @@
8 9
 
9 10
 {% block content %}
10 11
 <h1>My Store</h1>
12
+<!-- 
11 13
 <form method=post>
12 14
     {% csrf_token %}
13 15
     <input type='text' name='name' class='form-control' placeholder='Store Name'/>
14 16
     <input type='submit' class='btn btn-primary' name='createStore' value="Create Store" />
15 17
 </form>
16
-<hr>
18
+<hr> -->
17 19
 <div class="d-flex align-items-start">
18 20
   <div class="nav flex-column nav-pills me-3 col-md-3 col-lg-2" id="v-pills-tab" role="tablist" aria-orientation="vertical">
19 21
       <a class="nav-link {{ mystore|yesno:"active," }}" id="v-pills-home-tab"  href="{% url "fruit:mystore" %}" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">Info</a>
20 22
       <a class="nav-link {{ product|yesno:"active," }}" id="v-pills-profile-tab"  href="{% url "fruit:product_index" %}" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false">Products</a>
21
-    <a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" data-bs-target="#v-pills-messages" type="button" role="tab" aria-controls="v-pills-messages" aria-selected="false">Inbox</a>
22
-    <a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" data-bs-target="#v-pills-settings" type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">Saled Items</a>
23
+    <a class="nav-link" id="v-pills-messages-tab" href="{% url "fruit:inbox_index" %}" type="button" role="tab" aria-controls="v-pills-messages" aria-selected="false">Inbox</a>
24
+    <a class="nav-link {{ sale_active|yesno:"active," }}" id="v-pills-settings-tab" href="{% url "fruit:sale_index" %}"  type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">Saled Items</a>
23 25
     <a class="nav-link" id="v-pills-vendor-tab" data-toggle="pill" data-bs-target="#v-pills-vendor" type="button" role="tab" aria-controls="v-pills-vendor" aria-selected="false">Vendors</a>
24 26
   </div>
25 27
   <div class="tab-content p-3 col-md-9 col-lg-10" id="v-pills-tabContent">
28
+      {% block breadcrumbs %}
29
+          {% clear_breadcrumbs %}
30
+          {% breadcrumb "My Store" "fruit:mystore" %}
31
+      {% endblock %}
32
+
33
+
34
+    {% render_breadcrumbs %} 
26 35
       {% block store_main %}
27 36
       {% endblock %}
28 37
   </div>

+ 36 - 30
app/fruit/templates/fruit/product_form.html

@@ -1,4 +1,4 @@
1
-{% extends "fruit/mystore.html" %}
1
+{% extends "fruit/product_index.html" %}
2 2
 {% load static %}
3 3
 {% load crispy_forms_tags %}
4 4
 
@@ -7,41 +7,47 @@
7 7
 {{ form2.media  }}
8 8
 {% endblock %}
9 9
 
10
+{% load django_bootstrap_breadcrumbs %}
11
+{% block breadcrumbs %}
12
+    {{ block.super }}
13
+    {% breadcrumb "Product Edit" "fruit:product_edit" pid  %}
14
+{% endblock %}
15
+
10 16
 {% block store_main %}
11 17
     Create Product
12 18
 
19
+
13 20
 <form  method="post" enctype="multipart/form-data">
14 21
     {% csrf_token %}
15 22
     {{ form | crispy  }}
16
-    <fieldset class="border p-2">
17
-        <legend class='w-auto d-inline-block form-legend p-3'>Photos</legend>
18
-        {{ form2.management_form }}
19
-        <div class='row'>
20
-        {% for f0  in form2 %}
21
-        <div class='col-md-3'>
22
-        <!-- {{ f0.fields }} -->
23
-
24
-            {{ f0.id  | as_crispy_field }}
25
-            {{ f0.name | as_crispy_field }}
26
-            {% if f0.instance.photo %}
27
-            <a href="{{ f0.instance.photo.url }}" target="_blank">
28
-                <img src="{{ f0.instance.photo.url  }}" width='100%' style='max-height:200px'></a>
29
-            {% endif %}
30
-            {{ f0.photo | as_crispy_field }}
31
-            
32
-            {{ f0.product | as_crispy_field }}
33
-            {{ f0.DELETE | as_crispy_field }}
34
-        </div>
35
-        {% endfor %}
36
-        </div>
37
-    </fieldset>
38
-    <br>
39
-    <input type='submit' class='btn btn-primary' name='updateStore' value="Update" />
23
+        <fieldset class="border p-2 row">
24
+            <legend class='w-auto d-inline-block form-legend p-3'>Photos</legend>
25
+            {{ form2.management_form }}
26
+            {% for f0  in form2 %}
27
+            <div class='col-md-3 border'>
28
+            <!-- {{ f0.fields }} -->
29
+
30
+                {{ f0.id  | as_crispy_field }}
31
+                {{ f0.name | as_crispy_field }}
32
+                {% if f0.instance.photo %}
33
+                <a href="{{ f0.instance.photo.url }}" target="_blank">
34
+                    <img src="{{ f0.instance.photo.url  }}" width='100%' style='max-height:200px'></a>
35
+                {% endif %}
36
+                {{ f0.photo | as_crispy_field }}
37
+                
38
+                {{ f0.order_n  | as_crispy_field }}
39
+                {{ f0.product | as_crispy_field }}
40
+                {{ f0.DELETE | as_crispy_field }}
41
+            </div>
42
+            {% endfor %}
43
+        </fieldset>
44
+        <br>
45
+        <input type='submit' class='btn btn-primary' name='updateStore' value="Update" />
40 46
 
41
-</form>
42
-<hr>
43
-<h2>SKUs</h2>
44
-<a href="{% url "fruit:create_sku" pk=object.pk %}" class='btn btn-primary'>Create SKU</a><br><br>
47
+    </form>
48
+    <hr>
49
+    <h2>SKUs</h2>
50
+    <a href="{% url "fruit:create_sku" pk=obj.pk %}" class='btn btn-primary'>Create SKU</a><br><br>
45 51
 
46 52
 <table class='table table-bordered  table-striped'>
47 53
     <thead>
@@ -50,7 +56,7 @@
50 56
     </thead>
51 57
     <tbody>
52 58
         
53
-        {% for o in  object.productsku_set.all %}
59
+        {% for o in  obj.productsku_set.all %}
54 60
             <tr>
55 61
                 <td><a href="{% url "fruit:edit_sku" pk=o.pk %}">{{ o.sku }}</a></td>
56 62
                 <td>{{ o.created_at }}</td>

+ 17 - 6
app/fruit/templates/fruit/product_index.html

@@ -5,21 +5,32 @@
5 5
 {% block header %}            
6 6
 {% endblock %}
7 7
 
8
+{% load django_bootstrap_breadcrumbs %}
9
+{% block breadcrumbs %}
10
+    {{ block.super }}
11
+    {% breadcrumb "Products" "fruit:product_index" %}
12
+{% endblock %}
13
+
8 14
 {% block store_main %}
9
-<a  href="{% url "fruit:product_create" %}">Create Product</a>
15
+<a  class='btn btn-primary' href="{% url "fruit:product_create" %}">Create Product</a>
16
+<hr>
17
+<h2>
18
+    Product Index</h2>
19
+{% include "fruit/_searchcenter.html" %}
10 20
 <hr>
11
-Product Index
12
-{{ products }}
21
+<!--
22
+    {{ products }} -->
13 23
 <table class='table table-borded table-striped'>
14 24
     <thead>
15
-        <tr><th>ID</th><th>Name</th><th>Created At</th></tr>
25
+        <tr><th>ID</th><th>Name</th><th>Price</th><th>Created At</th></tr>
16 26
     </thead>
17 27
     <tbody>
18
-{% for p in products %}
28
+{% for p in page_obj %}
19 29
         <tr>
20
-            <td><a href="{% url "fruit:product_edit" pk=p.pk %}">{{ p.id }}</a></td><td>{{ p.name }}</td><td>{{ p.created_at }}</td>
30
+            <td><a href="{% url "fruit:product_edit" pk=p.pk %}">{{ p.id }}</a></td><td>{{ p.name }}</td><td>{% firstof p.price  "-" %}</td><td>{{ p.created_at }}</td>
21 31
         </tr>
22 32
 {% endfor %}
23 33
     </tbody>
24 34
 </table>
35
+{% include "fruit/_paging.html" %}
25 36
 {% endblock %}

+ 25 - 0
app/fruit/templates/fruit/sale_form.html

@@ -0,0 +1,25 @@
1
+{% extends "fruit/sale_index.html" %}
2
+{% load static %}
3
+{% load crispy_forms_tags %}
4
+{% load django_bootstrap_breadcrumbs %}
5
+
6
+{% block header %}            
7
+{{ form.media  }}
8
+{% endblock %}
9
+
10
+{% block breadcrumbs %}
11
+    {{ block.super }}
12
+    {% breadcrumb "Sales Form" "fruit:sale_edit" form.instance.pk %}
13
+{% endblock %}
14
+
15
+{% block store_main %}
16
+<h2>Sale Form</h2>
17
+<form  method="post" enctype="multipart/form-data">
18
+    {% csrf_token %}
19
+    {{ form | crispy  }}
20
+    <br>
21
+    <input type='submit' class='btn btn-primary' value="Update" />
22
+
23
+</form>
24
+
25
+{% endblock %}

+ 41 - 0
app/fruit/templates/fruit/sale_index.html

@@ -0,0 +1,41 @@
1
+{% extends "fruit/mystore.html" %}
2
+{% load static %}
3
+{% load crispy_forms_tags %}
4
+
5
+{% block header %}            
6
+{% endblock %}
7
+
8
+{% load django_bootstrap_breadcrumbs %}
9
+{% block breadcrumbs %}
10
+    {{ block.super }}
11
+    {% breadcrumb "Sales" "fruit:sale_index" %}
12
+{% endblock %}
13
+
14
+{% block store_main %}
15
+<!--
16
+<a  class='btn btn-primary' href="{% url "fruit:product_create" %}">Create Product</a> -->
17
+<hr>
18
+<h2>
19
+    Sale Index</h2>
20
+{% include "fruit/_searchcenter.html" %}
21
+<hr>
22
+<table class='table table-borded table-striped'>
23
+    <thead>
24
+        <tr><th>ID</th><th>Product</th><th>SKU</th><th>Price</th><th>Unit(s)</th><th>UName</th><th>Total</th><th>Buyer</th><th>Created At</th></tr>
25
+    </thead>
26
+    <tbody>
27
+{% for p in page_obj %}
28
+        <tr>
29
+            <td><a href="{% url "fruit:sale_edit" pk=p.pk %}">{{ p.id }}</a></td><td>{{ p.product }}</td>
30
+            <td>{{ p.sku }}</td>
31
+            <td>{{ p.n_unit }}</td>
32
+            <td>{{ p.unit_name }}</td>
33
+            <td>{{ p.total }}</td>
34
+            <td>{{ p.buyer }}</td>
35
+            <td>{% firstof p.price  "-" %}</td><td>{{ p.created_at }}</td>
36
+        </tr>
37
+{% endfor %}
38
+    </tbody>
39
+</table>
40
+{% include "fruit/_paging.html" %}
41
+{% endblock %}

+ 7 - 1
app/fruit/templates/fruit/sku_form.html

@@ -1,4 +1,4 @@
1
-{% extends "fruit/mystore.html" %}
1
+{% extends "fruit/product_form.html" %}
2 2
 {% load static %}
3 3
 {% load crispy_forms_tags %}
4 4
 
@@ -6,6 +6,12 @@
6 6
 {{ form.media  }}
7 7
 {% endblock %}
8 8
 
9
+{% load django_bootstrap_breadcrumbs %}
10
+{% block breadcrumbs %}
11
+    {{ block.super }}
12
+    {% breadcrumb "SKU Edit" "fruit:sku_edit" pk=form.instance.pk  %}
13
+{% endblock %}
14
+
9 15
 {% block store_main %}
10 16
     SKU Form
11 17
 

+ 4 - 0
app/fruit/urls.py

@@ -11,6 +11,10 @@ urlpatterns = [
11 11
     path('sku/<pk>', views.edit_sku, name='edit_sku'),
12 12
     path('products/', views.product_index, name='product_index'),
13 13
     path('products/<pk>', views.product_edit, name='product_edit'),
14
+    path('sales/', views.sale_index, name='sale_index'),
15
+    path('sales/<pk>', views.sale_edit, name='sale_edit'),
16
+    path('inbox/', views.inbox_index, name='inbox_index'),
17
+    path('inbox/<pk>', views.inbox_edit, name='inbox_edit'),
14 18
     path('signup', views.signup, name='signup'),
15 19
 ]
16 20
 

+ 98 - 6
app/fruit/views.py

@@ -6,9 +6,10 @@ from django.contrib.auth.forms import UserCreationForm
6 6
 from django.urls import reverse
7 7
 from django.contrib.auth.decorators import login_required
8 8
 
9
-from fruit.models import Store, Product, Photo, ProductSKU
10
-from .forms import StoreForm, ProductForm, PhotoFormSet, InlinePhotoFormset, ProductSKUForm
9
+from fruit.models import Store, Product, Photo, ProductSKU, Sale, Inbox
10
+from .forms import StoreForm, ProductForm, InboxForm, SaleForm,  PhotoFormSet, InlinePhotoFormset, ProductSKUForm, ProductFilter, SaleFilter, InboxFilter
11 11
 from django.contrib import messages
12
+from django.core.paginator import Paginator
12 13
 
13 14
 
14 15
 def index(request):
@@ -48,7 +49,27 @@ def mystore(request):
48 49
 def product_index(request):
49 50
     stores = request.user.store_created.all().order_by("-created_at")
50 51
     products = stores[0].product_set.all().order_by("-created_at")
51
-    return render(request, 'fruit/product_index.html', {'products': products, 'product': True})
52
+
53
+    f = ProductFilter(request.GET, queryset=products)
54
+
55
+    paginator = Paginator(f.qs, 25)
56
+    page_number = request.GET.get('page')
57
+    page_obj = paginator.get_page(page_number)
58
+
59
+    return render(request, 'fruit/product_index.html', {'products': products, 'product': True, 'page_obj': page_obj, 'filter': f})
60
+
61
+@login_required
62
+def sale_index(request):
63
+    stores = request.user.store_created.all().order_by("-created_at")
64
+    o_qs = stores[0].sale_set.all().order_by("-created_at")
65
+
66
+    f = SaleFilter(request.GET, queryset=o_qs)
67
+
68
+    paginator = Paginator(f.qs, 25)
69
+    page_number = request.GET.get('page')
70
+    page_obj = paginator.get_page(page_number)
71
+
72
+    return render(request, 'fruit/sale_index.html', {'o_qs': o_qs, 'sale_active': True, 'page_obj': page_obj, 'filter': f})
52 73
 
53 74
 @login_required
54 75
 def create_product(request):
@@ -97,11 +118,14 @@ def create_sku(request, pk):
97 118
             message.error(request, "SKU  created failed")
98 119
             return redirect("fruit:create_sku", pk=int(pk))
99 120
 
100
-    return render(request, 'fruit/sku_form.html', {'form': form})
121
+    return render(request, 'fruit/sku_form.html', {'form': form, 'pid': p.pk})
101 122
 
102 123
 @login_required
103 124
 def edit_sku(request, pk):
125
+
104 126
     p = ProductSKU.objects.get(pk=pk)
127
+    p0 = p.product
128
+
105 129
     form = ProductSKUForm(instance=p)
106 130
     if request.method == "POST":
107 131
         form = ProductSKUForm(request.POST)
@@ -113,7 +137,7 @@ def edit_sku(request, pk):
113 137
             message.error(request, "SKU  created failed")
114 138
             return redirect("fruit:create_sku", pk=int(pk))
115 139
 
116
-    return render(request, 'fruit/sku_form.html', {'form': form})
140
+    return render(request, 'fruit/sku_form.html', {'form': form, 'pid': p0.pk})
117 141
 
118 142
 @login_required
119 143
 def product_edit(request, pk):
@@ -151,7 +175,75 @@ def product_edit(request, pk):
151 175
 
152 176
         return redirect("fruit:product_edit", pk =  int(pk))
153 177
 
154
-    return render(request, 'fruit/product_form.html', {'product': True, 'form': form, 'form2': form2, 'object': product })
178
+    return render(request, 'fruit/product_form.html', {'product': True, 'form': form, 'form2': form2, 'obj': product })
179
+
180
+@login_required
181
+def sale_edit(request, pk):
182
+    stores = request.user.store_created.all().order_by("-created_at")
183
+
184
+    obj = Sale.objects.get(pk=pk)
185
+    form = SaleForm(instance = obj)
186
+
187
+    if request.method == "POST":
188
+        form = SaleForm(request.POST)
189
+        if form.is_valid():
190
+            instance1 = form.save()
191
+            '''
192
+            print(instances)
193
+            for s in instances:
194
+                s.product = instance1
195
+                s.save()
196
+            '''
197
+            messages.success(request, "Sale Save")
198
+        else:
199
+            print("Invalid ")
200
+            if form.errors:
201
+                messages.error(request, form.errors)
202
+
203
+        return redirect("fruit:sale_edit", pk =  int(pk))
204
+
205
+    return render(request, 'fruit/sale_form.html', {'sale_active': True, 'form': form, 'object': obj})
206
+
207
+
208
+@login_required
209
+def inbox_index(request):
210
+    stores = request.user.store_created.all().order_by("-created_at")
211
+    o_qs = stores[0].inbox_set.all().order_by("-created_at")
212
+
213
+    f = InboxFilter(request.GET, queryset=o_qs)
214
+
215
+    paginator = Paginator(f.qs, 25)
216
+    page_number = request.GET.get('page')
217
+    page_obj = paginator.get_page(page_number)
218
+
219
+    return render(request, 'fruit/inbox_index.html', {'o_qs': o_qs, 'inbox_active': True, 'page_obj': page_obj, 'filter': f})
220
+
221
+@login_required
222
+def inbox_edit(request, pk):
223
+    stores = request.user.store_created.all().order_by("-created_at")
224
+
225
+    obj = Inbox.objects.get(pk=pk)
226
+    form = InboxForm(instance = obj)
227
+
228
+    if request.method == "POST":
229
+        form = InboxForm(request.POST)
230
+        if form.is_valid():
231
+            instance1 = form.save()
232
+            '''
233
+            print(instances)
234
+            for s in instances:
235
+                s.product = instance1
236
+                s.save()
237
+            '''
238
+            messages.success(request, "Sale Save")
239
+        else:
240
+            print("Invalid ")
241
+            if form.errors:
242
+                messages.error(request, form.errors)
243
+
244
+        return redirect("fruit:sale_edit", pk =  int(pk))
245
+
246
+    return render(request, 'fruit/inbox_form.html', {'inbox_active': True, 'form': form, 'object': obj})
155 247
 
156 248
 def signup(request):
157 249
     if request.method == 'POST':

+ 3 - 0
app/requirements.txt

@@ -14,3 +14,6 @@ Pillow
14 14
 django-quill-editor
15 15
 django-taggit
16 16
 django-crispy-forms
17
+django-filter
18
+django-paypal
19
+django-bootstrap-breadcrumbs

BIN
app/shaqfindbed/__pycache__/settings.cpython-39.pyc


+ 3 - 0
app/shaqfindbed/settings.py

@@ -47,12 +47,14 @@ INSTALLED_APPS = [
47 47
     'dal_select2',
48 48
     'mptt',
49 49
     'django_google_maps',
50
+    'django_bootstrap_breadcrumbs',
50 51
     'django.contrib.admin',
51 52
     'django.contrib.auth',
52 53
     'django.contrib.contenttypes',
53 54
     'django.contrib.sessions',
54 55
     'django.contrib.messages',
55 56
     'import_export',
57
+    'django_filters',
56 58
     'django_quill',
57 59
     'crispy_forms',
58 60
     'taggit',
@@ -171,3 +173,4 @@ LOGIN_REDIRECT_URL = '/fruit/mystore'
171 173
 LOGIN_URL = '/login'
172 174
 
173 175
 CRISPY_TEMPLATE_PACK = "bootstrap4"
176
+BREADCRUMBS_TEMPLATE = "django_bootstrap_breadcrumbs/bootstrap4.html"

tum/whitesports - Gogs: Simplico Git Service

Keine Beschreibung

feed-rss2.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * RSS2 Feed Template for displaying RSS2 Posts feed.
  4. *
  5. * @package WordPress
  6. */
  7. header( 'Content-Type: ' . feed_content_type( 'rss2' ) . '; charset=' . get_option( 'blog_charset' ), true );
  8. $more = 1;
  9. echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
  10. /**
  11. * Fires between the xml and rss tags in a feed.
  12. *
  13. * @since 4.0.0
  14. *
  15. * @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments',
  16. * 'rdf', 'atom', and 'atom-comments'.
  17. */
  18. do_action( 'rss_tag_pre', 'rss2' );
  19. ?>
  20. <rss version="2.0"
  21. xmlns:content="http://purl.org/rss/1.0/modules/content/"
  22. xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  23. xmlns:dc="http://purl.org/dc/elements/1.1/"
  24. xmlns:atom="http://www.w3.org/2005/Atom"
  25. xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  26. xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  27. <?php
  28. /**
  29. * Fires at the end of the RSS root to add namespaces.
  30. *
  31. * @since 2.0.0
  32. */
  33. do_action( 'rss2_ns' );
  34. ?>
  35. >
  36. <channel>
  37. <title><?php wp_title_rss(); ?></title>
  38. <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
  39. <link><?php bloginfo_rss( 'url' ); ?></link>
  40. <description><?php bloginfo_rss( 'description' ); ?></description>
  41. <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
  42. <language><?php bloginfo_rss( 'language' ); ?></language>
  43. <sy:updatePeriod>
  44. <?php
  45. $duration = 'hourly';
  46. /**
  47. * Filters how often to update the RSS feed.
  48. *
  49. * @since 2.1.0
  50. *
  51. * @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly',
  52. * 'yearly'. Default 'hourly'.
  53. */
  54. echo apply_filters( 'rss_update_period', $duration );
  55. ?>
  56. </sy:updatePeriod>
  57. <sy:updateFrequency>
  58. <?php
  59. $frequency = '1';
  60. /**
  61. * Filters the RSS update frequency.
  62. *
  63. * @since 2.1.0
  64. *
  65. * @param string $frequency An integer passed as a string representing the frequency
  66. * of RSS updates within the update period. Default '1'.
  67. */
  68. echo apply_filters( 'rss_update_frequency', $frequency );
  69. ?>
  70. </sy:updateFrequency>
  71. <?php
  72. /**
  73. * Fires at the end of the RSS2 Feed Header.
  74. *
  75. * @since 2.0.0
  76. */
  77. do_action( 'rss2_head' );
  78. while ( have_posts() ) :
  79. the_post();
  80. ?>
  81. <item>
  82. <title><?php the_title_rss(); ?></title>
  83. <link><?php the_permalink_rss(); ?></link>
  84. <?php if ( get_comments_number() || comments_open() ) : ?>
  85. <comments><?php comments_link_feed(); ?></comments>
  86. <?php endif; ?>
  87. <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator>
  88. <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
  89. <?php the_category_rss( 'rss2' ); ?>
  90. <guid isPermaLink="false"><?php the_guid(); ?></guid>
  91. <?php if ( get_option( 'rss_use_excerpt' ) ) : ?>
  92. <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
  93. <?php else : ?>
  94. <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
  95. <?php $content = get_the_content_feed( 'rss2' ); ?>
  96. <?php if ( strlen( $content ) > 0 ) : ?>
  97. <content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded>
  98. <?php else : ?>
  99. <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
  100. <?php endif; ?>
  101. <?php endif; ?>
  102. <?php if ( get_comments_number() || comments_open() ) : ?>
  103. <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( null, 'rss2' ) ); ?></wfw:commentRss>
  104. <slash:comments><?php echo get_comments_number(); ?></slash:comments>
  105. <?php endif; ?>
  106. <?php rss_enclosure(); ?>
  107. <?php
  108. /**
  109. * Fires at the end of each RSS2 feed item.
  110. *
  111. * @since 2.0.0
  112. */
  113. do_action( 'rss2_item' );
  114. ?>
  115. </item>
  116. <?php endwhile; ?>
  117. </channel>
  118. </rss>